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 TestGetTribesByAppUrl 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 TestGetTribesByAppUrl 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 TestGetTribesByAppUrl test cases e.g. mockDb.On("GetTribe", mock.Anything).Return(db.Tribe{ UUID: mockUUID, OwnerPubKey: mockPubKey, }).Once().
Change the database parameter in tHandler := NewTribeHandler(mockDb) to tHandler := NewTribeHandler(db.TestDb)
Create a tribe using the db.TestDb.CreateOrEditTribe() function e.g
Context
Currently, we test the TestGetTribesByAppUrl 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:
TestGetTribesByAppUrl
to connect to the Test DBThe test will throw a dereference error if not connected to a DB.
TestGetTribesByAppUrl
test cases e.g.mockDb.On("GetTribe", mock.Anything).Return(db.Tribe{ UUID: mockUUID, OwnerPubKey: mockPubKey, }).Once()
.tHandler := NewTribeHandler(mockDb)
totHandler := NewTribeHandler(db.TestDb)
mockAppURL
values frommockAppURL:= "valid_uuid"
tomockAppURL := tribe.AppURL
Assertions
Acceptance Criteria
TestGetTribesByAppUrl
TestGetTribesByAppUrl
refactor passesTestGetTribesByAppUrl
should not break existing test flows.Here is an example Real DB Test
The text was updated successfully, but these errors were encountered: