Skip to content

Conversation

@fank
Copy link
Member

@fank fank commented Jan 30, 2026

Summary

  • Add comprehensive unit tests for internal/server/operation.go and internal/storage/converter.go
  • Improves coverage for helper functions, error paths, and edge cases

Changes

internal/server/operation_test.go (+184 lines)

Test Purpose
TestGetByID_NotFound Error path when operation doesn't exist
TestSelectPending Filter operations by pending conversion status
TestUpdateConversionStatus Verify status update functionality
TestUpdateStorageFormat Verify format update functionality
TestMigrationRerun Idempotent migration on existing DB
TestGetTypesEmpty Empty database edge case
TestSelectAllEmpty Empty database edge case
TestSelectPendingEmpty Empty database edge case

internal/storage/converter_test.go (+339 lines)

Test Purpose
TestSideIndexToSide Side enum conversion with boundary cases
TestStringToEntityType Entity type string parsing
TestToFloat64 Interface to float64 conversion
TestToString Interface to string conversion
TestConverter_ParseMarkerPosition Marker coordinate extraction
TestConverter_CalculateEndFrame Frame count calculation from entities
TestConverter_ParseEvent_Distance Event distance parsing
TestConverter_GetEntityStateAtFrame Entity state lookup

Coverage Improvements

Package Before After
storage 88.5% 92.9%
server 89.6% 89.9%
Overall 44.4% 45.6%

Test plan

  • All existing tests pass
  • New tests pass
  • Coverage metrics verified

Add comprehensive unit tests:

operation_test.go (+184 lines):
- TestGetByID_NotFound: error path for missing operations
- TestSelectPending: filtering by pending conversion status
- TestUpdateConversionStatus: status update verification
- TestUpdateStorageFormat: format update verification
- TestMigrationRerun: idempotent migration handling
- TestGetTypesEmpty/SelectAllEmpty/SelectPendingEmpty: empty DB edge cases

converter_test.go (+339 lines):
- TestSideIndexToSide: side enum conversion with edge cases
- TestStringToEntityType: entity type string parsing
- TestToFloat64/TestToString: interface type conversion helpers
- TestConverter_ParseMarkerPosition: marker coordinate extraction
- TestConverter_CalculateEndFrame: frame count calculation
- TestConverter_ParseEvent_Distance: event distance parsing
- TestConverter_GetEntityStateAtFrame: entity state lookup

Coverage improvements:
- storage: 88.5% → 92.9%
- server: 89.6% → 89.9%
- Overall: 44.4% → 45.6%
@github-actions
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/web/internal/server 89.87% (+0.22%) 👍
github.com/OCAP2/web/internal/storage 92.90% (+4.44%) 👍

Coverage by file

Changed unit test files

  • github.com/OCAP2/web/internal/server/operation_test.go
  • github.com/OCAP2/web/internal/storage/converter_test.go

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