Skip to content

Conversation

@fank
Copy link
Member

@fank fank commented Jan 30, 2026

Summary

  • Add tests for error paths and edge cases in conversion and server packages
  • Conversion coverage: 76.3% → 91.5%
  • Server coverage: 88.5% → 89.6%
  • Overall coverage: 43.8% → 44.4%

Changes

conversion/worker_test.go (+300 lines)

Added errorMockRepo to test error paths in conversion worker:

Test Purpose
TestProcessOnce_SelectPendingError Database error handling
TestProcessOnce_ConversionFailureStatusUpdateError Status update failure after conversion error
TestConvertOperation_UpdateConvertingStatusError Error when setting "converting" status
TestConvertOperation_UpdateStorageFormatError Error when updating storage format
TestConvertOperation_UpdateCompletedStatusError Error when setting "completed" status
TestConvertOperation_UpdateDurationError Duration update failure (warning only)
TestConvertOperation_InvalidStorageFormat Unknown storage engine error

server/handler_test.go (+450 lines)

Added edge case tests for handlers:

Test Purpose
TestGetOperationFormat_EmptyStorageFormat Empty format defaults to json
TestGetOperationFormat_UnknownFormat Unknown format fallback to json
TestGetOperationManifest_FlatBuffers FlatBuffers content type header
TestGetOperationManifest_JSONFormat JSON returns decoded manifest
TestGetOperationChunk_FlatBuffers FlatBuffers chunk content type
TestGetOperationChunk_EmptyStorageFormat Empty format default behavior
TestGetMarker_WithExtension Deprecated .png extension stripping
TestGetAmmo_WithPaaExtension .paa extension stripping
TestStoreOperation_MissingFile Missing file upload returns BadRequest
TestStoreOperation_InvalidMissionDuration Invalid duration parsing
TestStoreOperation_WrongSecret Wrong secret returns Forbidden

Test plan

  • All existing tests pass
  • All new tests pass
  • Coverage verified with go test -cover ./...

Add tests for error paths and edge cases in conversion and server packages:

conversion/worker_test.go:
- Add errorMockRepo for testing error paths
- TestProcessOnce_SelectPendingError: Test SelectPending failure
- TestProcessOnce_ConversionFailureStatusUpdateError: Test status update failure
- TestConvertOperation_UpdateConvertingStatusError: Test converting status error
- TestConvertOperation_UpdateStorageFormatError: Test format update error
- TestConvertOperation_UpdateCompletedStatusError: Test completed status error
- TestConvertOperation_UpdateDurationError: Test duration update (warning only)
- TestConvertOperation_InvalidStorageFormat: Test unknown storage engine

server/handler_test.go:
- TestGetOperationFormat_EmptyStorageFormat: Test empty format defaults to json
- TestGetOperationFormat_UnknownFormat: Test unknown format fallback
- TestGetOperationManifest_FlatBuffers: Test flatbuffers content type
- TestGetOperationManifest_JSONFormat: Test JSON format returns decoded manifest
- TestGetOperationChunk_FlatBuffers: Test flatbuffers chunk content type
- TestGetOperationChunk_EmptyStorageFormat: Test empty format default
- TestGetMarker_WithExtension: Test deprecated .png extension stripping
- TestGetAmmo_WithPaaExtension: Test .paa extension stripping
- TestStoreOperation_MissingFile: Test missing file upload error
- TestStoreOperation_InvalidMissionDuration: Test invalid duration
- TestStoreOperation_WrongSecret: Test forbidden on wrong secret

Coverage improvements:
- conversion: 76.3% -> 91.5%
- server: 88.5% -> 89.6%
- Overall: 43.8% -> 44.4%
@github-actions
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/web/internal/conversion 91.53% (+15.25%) 🎉
github.com/OCAP2/web/internal/server 89.65% (+1.10%) 👍

Coverage by file

Changed unit test files

  • github.com/OCAP2/web/internal/conversion/worker_test.go
  • github.com/OCAP2/web/internal/server/handler_test.go

@fank fank merged commit 7cda202 into main Jan 30, 2026
4 checks passed
@fank fank deleted the test/improve-coverage-phase4 branch January 30, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants