Write TestGetElectionResults_NotFound
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user