Testing Guide¶
Running Tests¶
Run all tests with:
go test ./pkg/...
Test Structure¶
The project uses table-driven tests for all major logic in:
pkg/stacker/stacker_test.go
pkg/immich/client_test.go
Test Coverage¶
To check test coverage:
go test -cover ./pkg/...
For a detailed coverage report:
go test -coverprofile=coverage.out ./pkg/...
go tool cover -html=coverage.out
Writing Tests¶
When writing new tests:
- Use table-driven tests for similar test cases
- Test both success and failure scenarios
- Include edge cases
- Mock external dependencies
- Use descriptive test names
Example test structure:
func TestStackBy(t *testing.T) {
tests := []struct {
name string
input []Asset
expected []Stack
}{
{
name: "basic stacking",
input: []Asset{
// test data
},
expected: []Stack{
// expected results
},
},
// more test cases
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := StackBy(tt.input)
// assertions
})
}
}