Write TestGetElectionResults_NotFound

This commit is contained in:
2025-01-17 13:59:37 +01:00
parent afac0f8f91
commit 60d1bb382c

View File

@ -786,4 +786,24 @@ func TestGetElectionResults(t *testing.T) {
} }
} }
// TODO write test for not found getElectionResults func TestGetElectionResults_NotFound(t *testing.T) {
app := newTestApplication(t)
server := newTestServer(t, app.routes())
defer server.Close()
mockVotes := app.votes.(*mockVoteModel)
mockVotes.
On("GetByElection", mock.Anything).
Return(&[]models.Vote{}, sql.ErrNoRows)
path := baseUri + "election/1/results"
code, _, body := server.get(t, path)
assert.Equal(t, http.StatusNotFound, code)
var response api.ElectionResultsResponse
err := json.Unmarshal([]byte(body), &response)
if err != nil {
t.Fatal(err)
}
}