Skip to content

Conversation

@fank
Copy link
Member

@fank fank commented Jan 30, 2026

Summary

  • Add error path and edge case tests for storage engines and HTTP handlers
  • Improves test coverage across json.go, flatbuffers.go, and handler.go

Changes

internal/storage/json_test.go (+93 lines)

Test Purpose
TestJSONEngineInvalidGzip Invalid gzip data error path
TestJSONEngineInvalidJSONInGzip Invalid JSON inside gzip file
TestJSONEngineInvalidJSON Invalid plain JSON file
TestJSONEngineEntityWithNoType Non-map entity in entities array
TestJSONEngineEntitiesNotArray Entities field not an array

internal/storage/flatbuffers_test.go (+186 lines)

Test Purpose
TestFlatBuffersEngineChunkCountError ChunkCount when manifest read fails
TestFlatBuffersEngineConvertInvalidJSON Convert with invalid JSON input
TestFlatBuffersEngineConvertContextCancelled Context cancellation during convert
TestFlatBuffersEngineConvertWithEvents Conversion including events
TestFlatBuffersEngineConvertWithCrewInVehicle Conversion with vehicle crew data

internal/server/handler_test.go (+190 lines)

Test Purpose
TestGetOperationManifest_JSONError Manifest load error for JSON format
TestGetOperationManifest_ProtobufReadError Reader error for protobuf format
TestGetOperationChunk_JSONNotSupported Chunk request on JSON format
TestGetCapture_MissingFile Missing capture file error
TestGetCaptureFile_MissingFile Missing file download error

Coverage Improvements

Package Before After
storage 92.9% 95.0%
server 89.9% 90.3%
Overall 45.6% 46.3%

Test plan

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

fank added 2 commits January 30, 2026 15:55
json_test.go (+93 lines):
- TestJSONEngineInvalidGzip: invalid gzip data error path
- TestJSONEngineInvalidJSONInGzip: invalid JSON in gzip file
- TestJSONEngineInvalidJSON: invalid plain JSON file
- TestJSONEngineEntityWithNoType: non-map entity handling
- TestJSONEngineEntitiesNotArray: invalid entities format

flatbuffers_test.go (+186 lines):
- TestFlatBuffersEngineChunkCountError: manifest read error path
- TestFlatBuffersEngineConvertInvalidJSON: invalid JSON error path
- TestFlatBuffersEngineConvertContextCancelled: context cancellation
- TestFlatBuffersEngineConvertWithEvents: events conversion coverage
- TestFlatBuffersEngineConvertWithCrewInVehicle: crew data coverage

Coverage: storage 92.9% → 95.0%
handler_test.go (+190 lines):
- TestGetOperationManifest_JSONError: manifest load error for JSON
- TestGetOperationManifest_ProtobufReadError: reader error for protobuf
- TestGetOperationChunk_JSONNotSupported: chunk request on JSON format
- TestGetCapture_MissingFile: missing capture file error
- TestGetCaptureFile_MissingFile: missing capture file download error

Coverage: server 89.9% → 90.3%
- GetOperationManifest: 79.2% → 87.5%
@github-actions
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/web/internal/server 90.31% (+0.44%) 👍
github.com/OCAP2/web/internal/storage 95.03% (+2.13%) 👍

Coverage by file

Changed unit test files

  • github.com/OCAP2/web/internal/server/handler_test.go
  • github.com/OCAP2/web/internal/storage/flatbuffers_test.go
  • github.com/OCAP2/web/internal/storage/json_test.go

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