-
Notifications
You must be signed in to change notification settings - Fork 62
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 Test For TestMakeBountyPayment To Use A Real Postgres DB For The Test #1855
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
TestMakeBountyPayment
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:
TestMakeBountyPayment
to connect to the Test DBThe test will throw a dereference error if not connected to a DB.
TTestPollInvoice
test cases e.g.mockDb.On("ProcessBountyPayment", mock.AnythingOfType("db.NewPaymentHistory"), mock.AnythingOfType("db.NewBounty")).Return(nil)
.bHandler := NewBountyHandler(mockHttpClient, mockDb)
tobHandler := NewBountyHandler(mockHttpClient, db.TestDb)
db.TestDb.CreateOrPerson()
function e.gdb.TestDb.CreateOrEditWorkspace()
function e.gworkspace:= db.TestDb.GetWorkspaceByUuid(workspace.Uuid)
db.TestDB.CreateWorkspaceBudget()
function e.gdbBounty := db.TestDb.GetBountyDataByCreated(bounty.Created)
functionauthorizedCtx
value fromauthorizedCtx := context.WithValue(ctx, auth.ContextKey, "valid-key")
toauthorizedCtx := context.WithValue(ctx, auth.ContextKey, person.OwnerPubkey)
Id
e.g.r.Post("gobounties/pay/{dbBounty.ID}", bountyHandler.MakeBountyPayment)
db.TestDb.GetBountyByCreated(bounty.Created)
functiondb.TestDb.GetWorkspaceBudget(workspace.Uuid)
functionAssertions
Acceptance Criteria
TestMakeBountyPayment
TestMakeBountyPayment
refactor passesTestMakeBountyPayment
should not break existing test flows.Here is an example Real DB Test
The text was updated successfully, but these errors were encountered: