Refactor TestGetTotalTribes
To Use A Real Postgres DB For The Test
#1780
Labels
TestGetTotalTribes
To Use A Real Postgres DB For The Test
#1780
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
The text was updated successfully, but these errors were encountered: