You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, we test the TestGetPersonByUuid with a mock database.
Design
We want to refactor the tests to use a real Postgres DB spun up on docker, follow the instructions in the Unit Testing section of README.md to run spin up a database in docker, and change the test_config.go configuration.
After spinning up the Postgres DB container:
Add this line of code on the first line and second of the test function TestGetPersonByUuid to connect to the Test DB
Context
Currently, we test the TestGetPersonByUuid with a mock database.
Design
We want to refactor the tests to use a real Postgres DB spun up on docker, follow the instructions in the
Unit Testing
section of README.md to run spin up a database in docker, and change thetest_config.go
configuration.After spinning up the Postgres DB container:
TestGetPersonByUuid
to connect to the Test DBThe test will throw a dereference error if not connected to a DB.
TestGetPersonByUuid
test cases e.g.mockDb.On("GetPersonByPubkey", "test-key").Return(db.Person{}).Once()
.pHandler := NewPeopleHandler(mockDb)
topHandler := NewPeopleHandler(db.TestDB)
db.TestDb.CreateOrEditPerson()
e.gperson := db.TestDb.GetPerson(person.ID)
person.Uuid
req, err := http.NewRequestWithContext(context.WithValue(context.Background(), chi.RouteCtxKey, rctx), http.MethodGet, "/uuid", nil) assert.NoError(t, err)
rctx.URLParams.Add("uuid", "uuid")
torctx.URLParams.Add("uuid", person.Uuid)
Assertions
Acceptance Criteria
TestGetPersonByUuid
TestGetPersonByUuid
refactor passesTestGetPersonByUuid
should not break existing test flows.Here is an example Real DB Test
The text was updated successfully, but these errors were encountered: