How to Run Tests
Txlog Server has a comprehensive test suite covering models, controllers, and integration scenarios.
Running All Tests
To run the entire test suite:
go test ./...Running Specific Tests
To run tests for a specific package (e.g., models):
go test ./models -vTo run a specific test function:
go test ./models -v -run TestAssetManager_UpsertAssetTest Database
The tests require a PostgreSQL database. By default, they expect a database named txlog_test on localhost.
Create the Test Database:
bashcreatedb txlog_test(Or use your preferred method to create a Postgres DB).
Connection String: The tests use the following default connection string:
host=localhost port=5432 user=postgres password=postgres dbname=txlog_test sslmode=disableIf your local setup is different, you may need to modify the
setupTestDBhelper in the test files.
Integration Tests
Integration tests in the tests/ directory simulate full user scenarios. They are slower but verify the system end-to-end.
go test ./tests -vFor more details on the testing strategy, see TESTING.md.
