Add comprehensive test coverage for cache and validation features
This commit addresses the remaining Copilot review suggestions by adding
test coverage for the new functionality introduced in PR #120.
New Tests Added:
1. Unit Tests for validateGzipFile (6 test cases)
- ✅ Accepts valid gzip files
- ✅ Rejects files with invalid magic bytes
- ✅ Rejects files shorter than 2 bytes
- ✅ Rejects empty files
- ✅ Rejects non-existent files
- ✅ Accepts files with correct magic bytes (validates header only)
2. Integration Test for --clean-cache Flag
- ✅ Verifies cache is created on first build
- ✅ Verifies --clean-cache removes and recreates cache
- ✅ Ensures build completes successfully after cleaning
Implementation Details:
- Exported validateGzipFile from Foliage.FetchURL for testing
- Created new test module: tests/Foliage/Tests/FetchURL.hs
- Updated foliage.cabal to include:
- New test module and dependencies
- app/ directory in test hs-source-dirs for module access
- Required dependencies: aeson, binary, hashable, shake, network-uri, temporary
- All 10 tests pass (6 unit + 4 integration)
Test Results:
✅ validateGzipFile: 6/6 tests pass
✅ Integration tests: 4/4 tests pass (one, --no-signatures, --write-metadata, --clean-cache)
This provides confidence that:
- Gzip validation logic works correctly and won't regress
- The --clean-cache flag operates as expected
- Cache corruption prevention features are properly tested