-
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 TestGetBountyById To Use A Real Postgres DB For The Test #1721
Comments
@elraphty Assign |
@elraphty Please assign me |
@elraphty Could you please assign me? |
@AbdulWahab3181 You get the next one, just comment on it. |
Ok Thanks |
@elraphty Please assign the next task to me after @AbdulWahab3181. |
@elraphty Can I take this one if Mirza is unable to complete it? |
Context
Currently, we test the TestGetBountyById 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:
TestGetBountyById
to connect to the Test DBThe test will throw a dereference error if not connected to a DB.
TestGetBountyById
test cases e.g.mockDb.On("GetPersonByPubkey", "test-key").Return(db.Person{}).Once()
.pHandler := NewPeopleHandler(mockDb)
topHandler := NewPeopleHandler(db.TestDB)
db.TestDb.CreateOrEditBounty()
e.gbountyInDb := db.TestDb.GetBountyByCreated(bounty.Created)
bountyInDb.Id
req, err := http.NewRequestWithContext(context.WithValue(context.Background(), chi.RouteCtxKey, rctx), http.MethodGet, "/bounty/1", nil) assert.NoError(t, err)
rctx.URLParams.Add("bountyId", strconv.Itoa(int(bounty.ID)))
torctx.URLParams.Add("bountyId", strconv.Itoa(int(bountyInDb.ID)))
Assertions
Acceptance Criteria
TestGetBountyById
TestGetBountyById
refactor passesTestGetBountyById
should not break existing test flows.Here is an example Real DB Test
The text was updated successfully, but these errors were encountered: