-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor TestGetListedPeople To Use A Real Postgres DB For The Test #1719
Labels
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context
Currently, we test the TestGetListedPeople 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:
TestGetListedPeople
to connect to the Test DBThe test will throw a dereference error if not connected to a DB.
TestGetListedPeople
test cases e.g.mockDb.On("GetPersonByPubkey", "test-key").Return(db.Person{}).Once()
.pHandler := NewPeopleHandler(mockDb)
topHandler := NewPeopleHandler(db.TestDB)
Unlisted: true
, and the other withUnlisted: false
using this db functiondb.TestDb.CreateOrEditPerson()
e.gperson := db.TestDb.GetPerson(person.ID)
OwnerAlias
req, err := http.NewRequestWithContext(context.WithValue(context.Background(), chi.RouteCtxKey, rctx), http.MethodGet, "/?page=1&limit=10&search=John", nil)
OwnerAlias
req, err := http.NewRequestWithContext(context.WithValue(context.Background(), chi.RouteCtxKey, rctx), http.MethodGet, "/?page=1&limit=10&languages=typescript", nil)
Assertions
Acceptance Criteria
TestGetListedPeople
TestGetListedPeople
refactor passesTestGetListedPeople
should not break existing test flows.Here is an example Real DB Test
The text was updated successfully, but these errors were encountered: