Skip to content

Conversation

@fank
Copy link
Member

@fank fank commented Jan 30, 2026

Summary

Continue test coverage improvements from #75. This PR adds comprehensive tests for previously untested functions in the handler, operation, and worker packages.

Coverage Improvements

Package Before After
internal/server 65% 88.5%
internal/conversion 64.4% 76.3%
Overall project 31.6% 36.9%

New/Extended Tests

handler_test.go (+500 lines)

  • TestGetOperations - filter by name, tag, date range
  • TestGetCustomize - customization settings endpoint
  • TestGetVersion - build version endpoint
  • TestStoreOperation - upload with success, wrong secret, invalid duration
  • TestGetCapture / TestGetCaptureFile - data download endpoints
  • TestGetMapTitle / TestGetStatic - static file serving with path traversal protection
  • TestCacheControl - middleware for cache headers
  • TestErrorHandler - error handling middleware
  • TestWithConversionTrigger - handler option
  • TestNewHandler / TestNewHandlerWithOptions - handler initialization

operation_test.go (+120 lines)

  • TestGetTypes - distinct tag retrieval
  • TestSelectAll - fetch all operations
  • TestUpdateMissionDuration - duration update
  • TestStoreDefaults - default values for storage format and conversion status
  • TestSelectWithFilters - comprehensive filter testing

worker_test.go (+170 lines)

  • TestDefaultConfig - default configuration values
  • TestNewWorker_Defaults - worker initialization defaults
  • TestTriggerConversion - async conversion (success)
  • TestTriggerConversion_Failure - async conversion (failure handling)
  • TestWorker_FlatBuffersFormat - flatbuffers conversion
  • TestWorker_ContextCancellation - graceful shutdown

Test plan

  • All existing tests pass
  • New tests pass
  • Coverage verified with go test -cover

Add comprehensive tests for previously untested functions:

handler_test.go:
- GetOperations, GetCustomize, GetVersion
- StoreOperation (with and without conversion trigger)
- GetCapture, GetCaptureFile, GetMapTitle, GetStatic
- cacheControl, errorHandler, WithConversionTrigger
- NewHandler with various options

operation_test.go:
- GetTypes, SelectAll, UpdateMissionDuration
- StoreDefaults, SelectWithFilters

worker_test.go:
- DefaultConfig, TriggerConversion (success and failure)
- NewWorker defaults, FlatBuffers format
- Context cancellation handling

Coverage improvements:
- internal/server: 88.5% (up from 65%)
- internal/conversion: 76.3% (up from 64.4%)
- Overall project: 36.9% (up from 31.6%)
@github-actions
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/web/internal/conversion 76.27% (+11.86%) 🎉
github.com/OCAP2/web/internal/server 88.55% (+23.57%) 🌟

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
  • github.com/OCAP2/web/internal/server/operation_test.go

@fank fank merged commit a89b619 into main Jan 30, 2026
4 checks passed
@fank fank deleted the test/improve-coverage-phase2 branch January 30, 2026 14:27
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