Backend for sphinx tribes and bounties. The bounty platform pays out in bitcoin. Sign up with Sphinx Chat, complete a bounty, and earn bitcoin! Go to our website for available bounties.
Currently, we test the TestGetTotalTribes 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 TestGetTotalTribes to connect to the Test DB
Context
Currently, we test the
TestGetTotalTribes
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:
TestGetTotalTribes
to connect to the Test DBThe test will throw a dereference error if not connected to a DB.
TestGetTotalTribes
test cases e.g.mockDb.On("GetTribesTotal", mock.Anything).Return(expectedTribesCount)
.tHandler := NewTribeHandler(mockDb)
totHandler := NewTribeHandler(db.TestDb)
db.TestDb.GetTribesTotal()
Assertions
Acceptance Criteria
TestGetTotalTribes
TestGetTotalTribes
refactor passesTestGetTotalTribes
should not break existing test flows.Here is an example Real DB Test