Draft
Conversation
This commit adds extensive unit test coverage for the Leo Bus project: Library Tests (test/lib/): - leolog.test.js: Tests for logging utilities including add, finalize, finalizeV2, systemRead, systemWrite, and loggers - getLeoConfigFromBusStack.test.js: Tests for CloudFormation stack configuration retrieval Bot Tests: - archive/test/archive.test.js: Tests for queue archiving functionality - bus-api/test/bus-api.test.js: Tests for API handlers (start, end, read, write, checkpoint) - cron-stream-trigger/test/cron-stream-trigger.test.js: Tests for DynamoDB stream trigger functionality - leo-monitor/test/leo-monitor.test.js: Tests for bot monitoring events - s3-load-trigger/test/s3-load-trigger.test.js: Tests for S3 file loading triggers Install Step Tests: - install/test/register.test.js: Tests for bot, system, and queue registration - install/test/add-crons.test.js: Tests for cron bot creation - install/test/s3-load-trigger.test.js: Tests for S3 notification and IAM setup Also fixes: - Existing install.test.js assertion to properly check sendCustomResourceResponse Total: 107 bot tests + 34 lib tests = 141 total tests passing Co-authored-by: clint.zirker <clint.zirker@rithum.com>
|
Cursor Agent can help with this pull request. Just |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Co-authored-by: clint.zirker <clint.zirker@rithum.com>
- npm test: Run all unit tests - npm run coverage: Run all tests with coverage report (text + HTML) - npm run coverage:libs: Run lib tests with coverage - npm run coverage:bots: Run bot tests with coverage Co-authored-by: clint.zirker <clint.zirker@rithum.com>
…-replicator - kinesis_processor: 8 tests covering record processing, skip configurations, data formats - firehose_processor: 6 tests covering S3 file processing, error handling - source-queue-replicator: 8 tests covering STS role assumption, cross-account replication Also adds: - .nycrc.json for nyc coverage configuration with --all flag - Updated .gitignore to exclude coverage artifacts Coverage improved from 47% to 78.57% (163 tests passing) Co-authored-by: clint.zirker <clint.zirker@rithum.com>
- Added 17 new tests for kinesis_processor covering: - ConditionalCheckFailedException handling with increment - Double ConditionalCheckFailedException with get fallback - Non-conditional errors - Skip events/bots via env vars - Different data encodings (gzipped, inflated, base64 JSON) - Multiple records processing - S3 mode for old/large batches - Sequence mismatch errors - handler2 pipe errors and DynamoDB updateMulti errors - Added 14 new tests for firehose_processor covering: - Different data encoding formats - Processing error handling - Event properties usage - Loop continuation with units - Checkpoint handling and errors - Missing id/event handling - S3 file processing errors Overall coverage: 80.15% (up from ~64%) Co-authored-by: clint.zirker <clint.zirker@rithum.com>
- firehose_processor: 89.04% (above 80% goal) - kinesis_processor: 70.04% (checkpoint logic requires integration testing) - install: 89.65% (up from 65.51%) Added tests for: - kinesis_processor: checkpoint success/error paths, archive/snapshot events, _cmd handling - firehose_processor: data encodings, multiple files, checkpoint handling - install: 3rd party install handling, error handling Note: kinesis_processor checkpoint logic (lines 337-396) requires complex stream processing with stats accumulation which is difficult to unit test without full integration testing of the leo-sdk stream pipeline. Co-authored-by: clint.zirker <clint.zirker@rithum.com>
Added mock toS3GzipChunks/toGzipChunks that emit chunks with stats data. However, the checkpoint code (lines 337-396) requires the stats to accumulate through the complex stream pipeline which is challenging to fully simulate in unit tests. Current coverage: - Overall: 89.28% (above 80% target) - firehose_processor: 89.04% (above 80% target) - kinesis_processor: 70.04% (checkpoint code requires integration testing) Co-authored-by: clint.zirker <clint.zirker@rithum.com>
- Fixed ls.pipeline mock to correctly pipe data from input to first stream - Mock now creates a duplex-like object that writes to the start of the pipeline - toS3GzipChunks mock now properly transforms events into chunks with stats - All handler tests now properly mock both promise-style and callback-style DynamoDB calls Coverage results: - Overall: 94.25% (up from 89.28%) - kinesis_processor: 90.32% (up from 70.04%) - GOAL ACHIEVED - firehose_processor: 89.04% - GOAL ACHIEVED The pipeline now correctly: 1. Receives events and pipes them through toS3GzipChunks 2. toS3GzipChunks transforms events into chunks with stats data 3. assignIds through processes chunks and accumulates stats 4. Checkpoint tasks are created and executed for accumulated stats Co-authored-by: clint.zirker <clint.zirker@rithum.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add comprehensive unit test coverage to key components and bots.
This PR introduces extensive unit tests across the repository's core libraries and Lambda functions to improve code reliability and maintainability.
Key Components Covered:
lib/):leolog.js,getLeoConfigFromBusStack.js,sendCustomResourceResponse.jsarchive,bus-api,cron-stream-trigger,leo-monitor,s3-load-trigger,install(specificallyregister,add-crons,s3-load-triggersteps)Test Coverage Added:
test/lib/leolog.test.jstest/lib/getLeoConfigFromBusStack.test.jsbots/archive/test/archive.test.jsbots/bus-api/test/bus-api.test.jsbots/cron-stream-trigger/test/cron-stream-trigger.test.jsbots/leo-monitor/test/leo-monitor.test.jsbots/s3-load-trigger/test/s3-load-trigger.test.jsbots/install/test/register.test.jsbots/install/test/add-crons.test.jsbots/install/test/s3-load-trigger.test.jsTotal: 141 tests passing