[Test Coverage] Add 100% test coverage for logs-audit command#1411
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
[Test Coverage] Add 100% test coverage for logs-audit command#1411github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
Add comprehensive tests for src/commands/logs-audit.ts, covering: - auditCommand with all three output formats (json, markdown, pretty) - Error cases: no log entries found, no policy manifest found - Filtering by rule ID, domain (case-insensitive), and decision - Exclusion of error:transaction-end-before-headers entries - Markdown output details: denied requests table, 50-row cap, policy flags - Pretty output details: denied requests section, 20-row cap - Source option and shouldLog callback behavior Coverage improvement: - logs-audit.ts: 0% to 100% statements (95.65% branches) - Overall: 80.53% to 83.86% statements (+3.33%) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Summary
This PR adds comprehensive unit tests for
src/commands/logs-audit.ts, bringing it from 0% to 100% statement coverage.Coverage Improvement
commands/logs-audit.tsWhat's Tested
The new test file
src/commands/logs-audit.test.ts(18 tests) covers:Error Paths
Output Formats
Filtering
--rule)--domain)--decision)error:transaction-end-before-headersoperational entriesOutput Details
discoverAndSelectSourceshouldLogcallback correctly suppresses logs for JSON formatTest Approach
All external dependencies are mocked (
logs-command-helpers,log-aggregator,audit-enricher,logger), ensuring tests are fast and deterministic with no filesystem or network I/O.Validation