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 TestGetWorkspaceBudgetHistory 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 TestGetWorkspaceBudgetHistory to connect to the Test DB
The test will throw a dereference error if not connected to a DB.
Remove all mock database functions in the TestGetWorkspaceBudgetHistory test cases e.g. mockDb.On("ProcessDeleteWorkspace", workspaceUUID).Return(nil).Once().
Change the database parameter in oHandler := NewWorkspaceHandler(mockDb) to oHandler := NewWorkspaceHandler(db.TestDb)
Create a workspace by using the db.TestDb.CreateOrEditWorkspace() function e.g
Context
Currently, we test the TestGetWorkspaceBudgetHistory 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:
TestGetWorkspaceBudgetHistory
to connect to the Test DBThe test will throw a dereference error if not connected to a DB.
TestGetWorkspaceBudgetHistory
test cases e.g.mockDb.On("ProcessDeleteWorkspace", workspaceUUID).Return(nil).Once()
.oHandler := NewWorkspaceHandler(mockDb)
tooHandler := NewWorkspaceHandler(db.TestDb)
db.TestDb.CreateOrEditWorkspace()
function e.gdb.TestDB.CreateWorkspaceBudget()
function e.gdb.TestDB.AddPaymentHistory()
function e.gworkspace:= db.TestDb.GetWorkspaceByUuid(workspace.Uuid)
workspaceUUID := "org-uuid"
toworkspaceUUID := workspace.Uuid
workspaceUUID
value to the workspace UuidworkspaceUUID := workspace.Uuid
Assertions
Acceptance Criteria
TestGetWorkspaceBudgetHistory
TestGetWorkspaceBudgetHistory
refactor passesTestGetWorkspaceBudgetHistory
should not break existing test flows.Here is an example Real DB Test
The text was updated successfully, but these errors were encountered: