Skip to content

test(scripts): fix Pester assertion syntax and add tar extraction tests#302

Merged
WilliamBerryiii merged 2 commits intomainfrom
feat/powershell-test-coverage-improvements
Jan 27, 2026
Merged

test(scripts): fix Pester assertion syntax and add tar extraction tests#302
WilliamBerryiii merged 2 commits intomainfrom
feat/powershell-test-coverage-improvements

Conversation

@WilliamBerryiii
Copy link
Copy Markdown
Member

Description

Fixes Pester assertion syntax error and expands test coverage for Get-VerifiedDownload.ps1 with tar archive extraction paths.

  • Fixed Should -Invoke syntax error (-Exactly 1-Times 1 -Exactly)
  • Added 6 tar extraction test cases covering tar.gz success, plain tar success, tar unavailable errors, and extraction failure handling
  • Added test for plain .tar archive type detection
  • Raised code coverage target from 70% to 80%
  • Removed unused $Uri parameter from mock blocks to satisfy PSScriptAnalyzer

Related Issue(s)

Resolves #264

Type of Change

Select all that apply:

Code & Documentation:

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature causing existing functionality to change)
  • Documentation update

Infrastructure & Configuration:

  • GitHub Actions workflow
  • Linting configuration (markdown, PowerShell, etc.)
  • Security configuration
  • DevContainer configuration
  • Dependency update

AI Artifacts:

  • Reviewed contribution with prompt-builder agent and addressed all feedback
  • Copilot instructions (.github/instructions/*.instructions.md)
  • Copilot prompt (.github/prompts/*.prompt.md)
  • Copilot agent (.github/agents/*.agent.md)

Note for AI Artifact Contributors:

  • Agents: Research, indexing/referencing other project (using standard VS Code GitHub Copilot/MCP tools), planning, and general implementation agents likely already exist. Review .github/agents/ before creating new ones.
  • Model Versions: Only contributions targeting the latest Anthropic and OpenAI models will be accepted. Older model versions (e.g., GPT-3.5, Claude 3) will be rejected.
  • See Agents Not Accepted and Model Version Requirements.

Other:

  • Script/automation (.ps1, .sh, .py)
  • Other (please describe):

Testing

  • Ran Invoke-Pester to verify all 37 tests pass
  • Confirmed code coverage increased to 82.76% (exceeds 80% target)
  • Ran Invoke-ScriptAnalyzer with project settings to verify 0 warnings

Checklist

Required Checks

  • Documentation is updated (if applicable)
  • Files follow existing naming conventions
  • Changes are backwards compatible (if applicable)
  • Tests added for new functionality (if applicable)

AI Artifact Contributions

N/A - Not an AI artifact contribution.

Required Automated Checks

The following validation commands must pass before merging:

  • Markdown linting: npm run lint:md
  • Spell checking: npm run spell-check
  • Frontmatter validation: npm run lint:frontmatter
  • Link validation: npm run lint:md-links
  • PowerShell analysis: npm run lint:ps

Security Considerations

  • This PR does not contain any sensitive or NDA information
  • Any new dependencies have been reviewed for security issues
  • Security-related scripts follow the principle of least privilege

Additional Notes

Coverage improvement addresses issue #264 by testing previously uncovered tar extraction branches in Get-VerifiedDownload.ps1.

🧪 - Generated by Copilot

@WilliamBerryiii WilliamBerryiii requested a review from a team as a code owner January 27, 2026 03:11
Copilot AI review requested due to automatic review settings January 27, 2026 03:11
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 27, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.77%. Comparing base (aeaed13) to head (9d5c2d1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #302      +/-   ##
==========================================
+ Coverage   37.34%   38.77%   +1.42%     
==========================================
  Files          15       15              
  Lines        2814     2814              
==========================================
+ Hits         1051     1091      +40     
+ Misses       1763     1723      -40     
Flag Coverage Δ
pester 38.77% <ø> (+1.42%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Pester assertion syntax error and significantly expands test coverage for the Get-VerifiedDownload.ps1 script, addressing issue #264.

Changes:

  • Fixed Should -Invoke syntax from -Exactly 1 to -Times 1 -Exactly for proper Pester 5.x compatibility
  • Added comprehensive test coverage for Invoke-VerifiedDownload function including 6 tar extraction scenarios (tar.gz success, plain tar success, tar unavailable errors, extraction failures)
  • Added test for plain .tar archive type detection in Get-ArchiveType function
  • Increased code coverage target from 70% to 80% to reflect the improved test coverage (PR reports 82.76% achieved)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
scripts/tests/pester.config.ps1 Increased code coverage target from 70% to 80% to reflect improved test coverage
scripts/tests/lib/Get-VerifiedDownload.Tests.ps1 Fixed Pester syntax error on line 243, added plain tar archive test, and added comprehensive test suite for Invoke-VerifiedDownload with 31 new test cases covering download, extraction, error handling, and tar archive scenarios

- fix Should -Invoke syntax error in download test
- add 6 tar extraction test cases for coverage
- raise coverage target from 70% to 80%

Resolves #264

🧪 - Generated by Copilot
@WilliamBerryiii WilliamBerryiii force-pushed the feat/powershell-test-coverage-improvements branch from ad306b6 to 0a59d46 Compare January 27, 2026 03:21
Copilot AI review requested due to automatic review settings January 27, 2026 06:30
@WilliamBerryiii WilliamBerryiii merged commit 2fcd595 into main Jan 27, 2026
20 checks passed
@WilliamBerryiii WilliamBerryiii deleted the feat/powershell-test-coverage-improvements branch January 27, 2026 06:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

$result.WasDownloaded | Should -BeTrue
$result.HashVerified | Should -BeTrue
$result.Path | Should -Exist
Should -Invoke -CommandName Invoke-WebRequest -Times 1 -Exactly
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description states "Fixed Should -Invoke syntax error (-Exactly 1-Times 1 -Exactly)" but all the Should -Invoke calls in this diff are part of newly added tests, not corrections to existing tests. The syntax used (-Times 1 -Exactly) is already correct. If there was a previous syntax error, it's not visible in this diff. Consider clarifying the PR description to accurately reflect what was changed.

Copilot uses AI. Check for mistakes.
$result.HashVerified | Should -BeTrue
$result.Path | Should -Exist
Should -Invoke -CommandName Invoke-WebRequest -Times 1 -Exactly
Should -Invoke -CommandName Get-FileHashValue -Times 1
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent use of -Exactly in mock assertions within the same test. Line 244 uses -Times 1 -Exactly while line 245 uses only -Times 1. For consistency and clarity, both assertions should use the same pattern since both commands are expected to be called exactly once. Recommend adding -Exactly to line 245.

Suggested change
Should -Invoke -CommandName Get-FileHashValue -Times 1
Should -Invoke -CommandName Get-FileHashValue -Times 1 -Exactly

Copilot uses AI. Check for mistakes.
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.

[Issue]: Add Pester tests for Invoke-VerifiedDownload orchestration function

4 participants