Repository navigation
Add Pester unit tests and an installer-arguments check for bootstrap-salt.ps1 - #2142
Merged
Merged
Conversation
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.
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.
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
Pester unit tests (tests/powershell/bootstrap-salt.Tests.ps1). The tests cover:
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.
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.
-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