This project now follows Go testing conventions properly:
main_test.go- Tests formain.go(health endpoint, route registration)auth_test.go- Tests forauth.go(IP extraction, context functions)user_test.go- Tests foruser.go(API key generation, hashing, display names, friend codes)ratelimit_test.go- Tests forratelimit.go(rate limiter functionality)score_test.go- Tests forscore.go(level parameter parsing, response structures)
integration_api_test.go- Full API integration tests with databaseintegration_test.go- Integration test setup and utilitiesintegration_utils.go- Helper functions for integration tests
- File Naming: Test files are named
<source>_test.goto match the source file they test - Package: All tests are in the same package (
main) as the source code - Function Naming: Test functions follow
TestFunctionNamepattern - Separation of Concerns: Unit tests vs integration tests are clearly separated
- Table-Driven Tests: Complex test cases use the standard Go table-driven pattern
- No Mixed Dependencies: Unit tests don't require external dependencies (database, network)
- ✅
main.go→main_test.go - ✅
auth.go→auth_test.go - ✅
user.go→user_test.go - ✅
ratelimit.go→ratelimit_test.go - ✅
score.go→score_test.go
- ✅
admin.go- Admin endpoints tested in integration tests - ✅
database.go- Database initialization tested through integration tests - ✅
routes.go- Route setup tested inmain_test.goand integration tests
# Run all tests
go test ./go/
# Run only unit tests (fast)
go test ./go/ -short
# Run integration tests
go test ./go/ -tags=integration
# Run specific test file
go test ./go/ -run TestHealth
# Run with coverage
go test ./go/ -cover