This repository was archived by the owner on Oct 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Requirements
Zoka-tech edited this page Mar 30, 2025
·
12 revisions
Well-written tests are essential to ensure stability when introducing new features or refactoring code, detect bugs early and ensure that each layer behaves correctly on its own and as part of the full system.
Before writing or running tests, it’s important to understand the technical setup behind each layer. This section explains what tools, dependencies and conventions are required depending on where the code lives.
To run and write backend tests, make sure the following are in place:
- Go environment set up (Go version as defined in the
go.modfile) - Use of
testify/assertfor expressive assertions - Use of test suite helpers for setup/cleanup where applicable
-
Requires Docker, since the tests use Testcontainers to spin up:
- Uses a real PostgreSQL database
- A Keycloak instance for authentication testing
-
Reset DB and seed data using helpers:
suite.ResetDB()suite.InsertSeed(...)
- No Docker required
- Tests use mocked repositories (via
/storage/_mock) - Mocks are defined using a mocking library
- No Docker required
- If your handlers call services, you can use mocks to isolate handler logic.
- You should use Fiber for consistency and clarity:
app := fiber.New()