Skip to content

Add Pester unit tests and an installer-arguments check for bootstrap-salt.ps1 - #2142

Merged
twangboy merged 2 commits into
saltstack:developfrom
twangboy:fix/issue/2139-phase2
Oct 2, 2026
Merged

twangboy merged 2 commits into
saltstack:developfrom
twangboy:fix/issue/2139-phase2

Conversation

@twangboy

@twangboy twangboy commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Phase 1 (#2141) added linting and Windows end-to-end checks for -ConfigureOnly and -RepoUrl. This PR covers the two remaining gaps from the issue: unit tests for the version-handling functions, and a check that -Minion and -Master reach the installer.

Changes

  1. Pester unit tests (tests/powershell/bootstrap-salt.Tests.ps1). The tests cover:

    • Get-MajorVersion and Test-SaltOnedirVersionIsGA, including prerelease and non-version inputs.
    • Compare-SaltCalVer: numeric versus lexical order (3006.24 is newer than 3006.3), missing components, and -N package releases.
    • Get-AvailableVersions against a local directory: latest and major-series selection, prereleases ignored, every directory still available by its exact name, and a -N release winning.
    • Get-HashFromArtifactory with mocks: success, API failure, and no query for non-Artifactory sources.

    The script is shipped and checksummed as a single file, so I didn't refactor it into a module. The tests parse bootstrap-salt.ps1 and load its top-level functions, so they exercise the real code.

  2. test-powershell CI job. It runs the tests on windows-latest under Windows PowerShell 5.1, which the script mostly runs on. It installs Pester 5 because the image ships Pester 3. The final pipeline status job now requires it.

  3. -Minion and -Master check (test-windows.yml). It compiles a small stub installer with Add-Type -OutputAssembly that records its command line. Then it runs bootstrap-salt.ps1 from a local -RepoUrl with defaults, -Minion, -Master, and both, and checks the exact arguments the installer receives.

What issues does this PR fix or reference?

Phase 2 of #2139

Add Pester 5 tests for the version handling in bootstrap-salt.ps1:
Get-MajorVersion, Test-SaltOnedirVersionIsGA, Compare-SaltCalVer,
Get-AvailableVersions (against a local directory) and
Get-HashFromArtifactory (mocked).

The script is distributed as a single file, so the tests load its
top-level functions by parsing it instead of requiring a refactor.

Run them in a new test-powershell job on Windows PowerShell 5.1 and
require it in the pipeline status.
Compile a small stub installer that records its command line, run
bootstrap-salt.ps1 from a local RepoUrl with and without -Minion and
-Master, and check the exact arguments the installer receives.
@twangboy twangboy self-assigned this Oct 2, 2026
@twangboy twangboy changed the title Fix/issue/2139 phase2 Add Pester unit tests and an installer-arguments check for bootstrap-salt.ps1 Oct 2, 2026
@twangboy
twangboy merged commit 1ef5086 into saltstack:develop Oct 2, 2026
158 checks passed
@twangboy
twangboy deleted the fix/issue/2139-phase2 branch October 2, 2026 19:27
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