Skip to content

Commit

Permalink
fixed unexpected error in other unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtabBukhari committed Jul 3, 2024
1 parent af1a5ad commit 5f7604c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions handlers/people_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,10 @@ func TestGetListedPeople(t *testing.T) {
db.TestDB.CreateOrEditPerson(person2)
db.TestDB.CreateOrEditPerson(person3)

fetchedPerson := db.TestDB.GetPerson(person2.ID)
fetchedPerson2 := db.TestDB.GetPerson(person3.ID)
fetchedPerson2 := db.TestDB.GetPerson(person2.ID)
fetchedPerson3 := db.TestDB.GetPerson(person3.ID)
person2.ID = fetchedPerson2.ID
person3.ID = fetchedPerson3.ID

t.Run("should return all listed users", func(t *testing.T) {
rr := httptest.NewRecorder()
Expand All @@ -476,8 +478,8 @@ func TestGetListedPeople(t *testing.T) {
assert.NoError(t, err)

expectedPeople := []db.Person{
fetchedPerson,
fetchedPerson2,
fetchedPerson3,
}

handler.ServeHTTP(rr, req)
Expand All @@ -486,8 +488,8 @@ func TestGetListedPeople(t *testing.T) {
err = json.Unmarshal(rr.Body.Bytes(), &returnedPeople)
assert.NoError(t, err)
assert.Equal(t, http.StatusOK, rr.Code)
assert.EqualValues(t, person2, fetchedPerson)
assert.EqualValues(t, person3, fetchedPerson2)
assert.EqualValues(t, person2, fetchedPerson2)
assert.EqualValues(t, person3, fetchedPerson3)
assert.EqualValues(t, expectedPeople, returnedPeople)
})

Expand All @@ -500,7 +502,7 @@ func TestGetListedPeople(t *testing.T) {
assert.NoError(t, err)

expectedPeople := []db.Person{
fetchedPerson,
fetchedPerson2,
}

handler.ServeHTTP(rr, req)
Expand All @@ -509,7 +511,7 @@ func TestGetListedPeople(t *testing.T) {
err = json.Unmarshal(rr.Body.Bytes(), &returnedPeople)
assert.NoError(t, err)
assert.Equal(t, http.StatusOK, rr.Code)
assert.EqualValues(t, person2, fetchedPerson)
assert.EqualValues(t, person2, fetchedPerson2)
assert.EqualValues(t, expectedPeople, returnedPeople)
})

Expand All @@ -527,7 +529,7 @@ func TestGetListedPeople(t *testing.T) {
assert.NoError(t, err)

expectedPeople := []db.Person{
fetchedPerson,
fetchedPerson2,
}

handler.ServeHTTP(rr, req)
Expand All @@ -536,7 +538,7 @@ func TestGetListedPeople(t *testing.T) {
err = json.Unmarshal(rr.Body.Bytes(), &returnedPeople)
assert.NoError(t, err)
assert.Equal(t, http.StatusOK, rr.Code)
assert.EqualValues(t, person2, fetchedPerson)
assert.EqualValues(t, person2, fetchedPerson2)
assert.EqualValues(t, expectedPeople, returnedPeople)
})

Expand Down

0 comments on commit 5f7604c

Please sign in to comment.