tests: add backend tests

This commit is contained in:
2026-01-19 12:46:07 -05:00
parent 5e8ac5e4b6
commit 627fcbafe1
9 changed files with 664 additions and 7 deletions

View File

@@ -16,6 +16,23 @@ golangci-lint run
go test ./...
```
## Testing
All Go code is tested using the [testify](https://github.com/stretchr/testify) framework with comprehensive test coverage:
- **Unit Tests**: Each function and method is thoroughly tested including edge cases
- **Integration Tests**: Store implementations are tested end-to-end
- **Error Handling**: All error conditions are explicitly tested
- **Concurrency**: Thread-safety of concurrent operations is verified
- **File Operations**: File-based storage tests use temporary directories
Tests follow these conventions:
- Use `require.NoError(t, err)` for fatal errors that break test flow
- Use `assert.NoError(t, err)` for non-fatal assertions
- Test both success and error paths for all methods
- Use table-driven tests where appropriate
- All tests are run with `go test ./...` or `go test -v ./...`
## Non-Negotiables
- ❌ No unhandled errors - always check `err`
@@ -40,7 +57,7 @@ go test ./...
- **DI**: Dependencies through constructors (`New*` functions)
- **HTTP**: Handlers receive `store.Store`, validate inputs, return proper status codes
- **Streaming**: Use `FlushWriter` for SSE/text streams
- **Storage**: JSON file-based (`FileStore` implementation)
- **Storage**: JSON file-based (`FileStore` implementation) with in-memory alternative (`InMemoryStore`)
## What Goes Where