-
Notifications
You must be signed in to change notification settings - Fork 0
fix(test): resolve 13 Windows-only Pester failures #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
01f504a
908d877
9b17e70
408397f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ words: | |
| - exrc | ||
| - gdefault | ||
| - gpgconf | ||
| - HKLM | ||
| - inputrc | ||
| - keepassxc | ||
| - kito | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,12 +20,13 @@ BeforeAll { | |
|
|
||
| function script:Write-Manifest { | ||
| param([string]$CategoriesJson) | ||
| $escapedHomeDir = $script:HomeDir.Replace('\', '\\') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Escaping only Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in commit 9b17e70 — the 'secret file missing is MISSING' test embeds |
||
| $body = @" | ||
| { | ||
| "version": 1, | ||
| "manager": "bitwarden", | ||
| "os": "linux", | ||
| "homeDir": "$script:HomeDir", | ||
| "homeDir": "$escapedHomeDir", | ||
| "ghqRoot": "", | ||
| "categories": $CategoriesJson | ||
|
Comment on lines
21
to
31
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in commit 9b17e70 — the 'secret file missing is MISSING' test was the only non-Windows-skipped case that embedded a Windows path in the categories JSON. Added |
||
| } | ||
|
|
@@ -124,9 +125,10 @@ Describe 'secret-status.ps1' { | |
|
|
||
| It 'secret file missing is MISSING' { | ||
| $f = Join-Path $HomeDir 'never-existed.txt' | ||
| $fJson = $f.Replace('\', '\\') | ||
| $cats = @" | ||
| {"gpg":[],"sshKeys":[],"sshHosts":[],"secretFiles":[ | ||
| {"label":"s","item":"S","target":"never-existed.txt","absPath":"$f","attachment":""} | ||
| {"label":"s","item":"S","target":"never-existed.txt","absPath":"$fJson","attachment":""} | ||
| ],"envFiles":[]} | ||
| "@ | ||
| Write-Manifest $cats | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,11 @@ Describe 'set-openssh-default-shell' -Skip:($IsWindows -eq $false) { | |
| } | ||
| } | ||
|
|
||
| It 'Test-DotfilesAdminElevation returns false for non-elevated session' { | ||
| It 'Test-DotfilesAdminElevation returns false for non-elevated session' -Skip:( | ||
| [System.Environment]::OSVersion.Platform -eq [System.PlatformID]::Win32NT -and | ||
| ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( | ||
|
Comment on lines
+32
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On Windows PowerShell 5.1, Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in commit 408397f — replaced |
||
| [Security.Principal.WindowsBuiltInRole]::Administrator) | ||
| ) { | ||
| Test-DotfilesAdminElevation | Should -BeFalse | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Windows CI or developer machines that do not have a real
ghqexecutable installed, this-Skipcondition prevents the test from running even though the test body immediately mocks bothGet-Command ghqand theghq rootcall. That means the ghq-trust path behavior is no longer covered in the common environment whereghqis absent; the same host-tool guard was also added to the blank-line case below, so regressions in this mocked flow can pass undetected.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rejecting: Pester 5 cannot mock a non-existent external command — it must be discoverable via
Get-Commandbefore the mock can wrap it. Whenghqis absent,Mock ghq { ... }throwsCommandNotFoundExceptionduring test setup rather than deferring to the mock body. The-Skipguard is therefore the correct fix; the alternative (mockingGet-Command 'ghq'to return a fake object, then also providing a stand-in function namedghq) would be a more invasive rewrite of the test structure than warranted. The test already has a companion case ('skips ghq trusted paths when ghq is not installed') that exercises the no-ghq code path without mocking the binary.