Skip to content

Feature/improve test coverage#119

Open
dmabry wants to merge 6 commits into
mainfrom
feature/improve-test-coverage
Open

Feature/improve test coverage#119
dmabry wants to merge 6 commits into
mainfrom
feature/improve-test-coverage

Conversation

@dmabry
Copy link
Copy Markdown
Owner

@dmabry dmabry commented May 8, 2026

No description provided.

dmabry added 6 commits May 8, 2026 12:43
- TestNew: Verify Manager initialization
- TestContext/Cancel/WaitGroup/Wait: Test all public methods
- TestSetupSignalHandler: Test signal handler setup
- TestSignalHandlerIntegration: Test cancellation propagation
- TestWaitWithMultipleGoroutines: Test WaitGroup coordination
- TestContextCancellation: Test context-based cancellation
- TestMultipleCancelCalls: Test idempotency
- All tests pass with race detector
- TestConfig: Config struct initialization and zero values
- TestWorkerStat: WorkerStat struct initialization and zero values
- TestRecordStatIncrValid/IncrInvalid: Atomic counter increments
- TestRecordStatConcurrentAccess: Thread safety with concurrent increments
- TestRecordStatConcurrentMixedAccess: Mixed concurrent read/write operations
- TestStatTotals: StatTotals struct initialization
- TestWorkerStats: Slice of WorkerStat
- TestHealth: Health struct initialization
- TestDashboardPage: DashboardPage struct with nested fields
- All tests pass with race detector
- 100% code coverage achieved
- TestCollectorRun: Stat collection loop with ticker
- TestCollectorRunWithLargeVolume: High volume stat processing
- TestCollectorRunContextCancellation: Context-based shutdown
- TestCollectorStatsHandler: JSON endpoint for worker stats
- TestCollectorStatsHandlerWithEmptyMap: Empty stats handling
- TestCollectorStatsHandlerWithError: Error handling in handler
- TestCollectorDashboardHandler: HTML dashboard rendering
- TestCollectorDashboardHandlerWithNilConfig: Nil config handling
- TestCollectorStop: Channel closure verification
- TestCollectorStopMultipleTimes: Idempotency test (known limitation)
- TestCollectorStatsAggregation: Stats aggregation logic
- TestCollectorChannelBuffering: Buffered channel handling
- TestCollectorConcurrentAccess: Thread safety with multiple senders
- All tests pass with race detector
- TestSingleCommandParseFlags: Flag parsing and defaults for single mode
- TestProxyCommandParseFlags: Flag parsing, target flags, and defaults for proxy mode
- TestTargetFlagsSet/String: Custom flag type for multiple targets
- TestRecordCommandParseFlags: Flag parsing and defaults for record mode
- TestReplayCommandParseFlags: Flag parsing, updatets flag, and defaults for replay mode
- TestBarrageCommandParseFlags: Flag parsing, web flags, config flag, and defaults for barrage mode
- All ParseFlags methods achieve 100% coverage
- Execute/Run* functions not tested (delegate to already-tested packages)
- All tests pass with race detector
- TestGenerateNetflow: Main NetFlow generation function
- TestIsValidNetFlow: Validation with correct/wrong versions and invalid payloads
- TestUpdateTimeStamp: Timestamp update functionality
- TestGetNetFlowSizes: Size reporting for header, template, and data
- TestHeaderSize/String: Header methods coverage
- TestFieldString: Field String method
- TestTemplateSize/sizeOfFields: Template size calculations
- TestTemplateFlowSetSize: TemplateFlowSet size method
- TestToBytesWithEmptyFlowSets: Edge case with no flow sets
- TestGenericFlowGenerateWithDifferentPorts: Various port/protocol combinations
- TestGenericFlowGenerateWithInvalidIP: Invalid IP handling
- TestDataFlowSetGenerateWithZeroPort/SpecificPort: Port selection logic
- TestTemplateFlowSetGenerateWithPadding: Padding calculation
- All previously uncovered functions now at 100% coverage
- ToBytes remains at 63.3% (error paths hard to trigger)
- Overall coverage improved from 54.3% to 88.4%
- All tests pass with race detector
- TestHealthHandler: Health endpoint with JSON response verification
- TestIndexHandler: Index endpoint with JSON response verification
- TestIndexHandlerErrorPath/HealthHandlerErrorPath: Error handling paths
- TestIndexHandlerWithDifferentMethods/HealthHandlerWithDifferentMethods: Multiple HTTP methods
- TestRunWebServer: Web server startup, endpoint testing, and shutdown
- TestRunWebServerWithDifferentPorts: Server on multiple ports
- TestRunWebServerWithDifferentIPs: Server on different IP addresses
- TestRunWebServerContextCancellation: Context-based shutdown verification
- TestRunWebServerEndpoints: All registered endpoints (/health, /stats, /dashboard)
- Improved coverage from 66.7% to 77.8%
- RunWebServer at 88.2%, handlers at 60% (error paths hard to trigger)
- All tests pass with race detector
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.

1 participant