Skip to content

Commit 2dff5a7

Browse files
committed
test: fix Windows test failures and lint warnings in the added suites
- Shortcuts: clear the destination in BeforeEach so the 'destination absent' cases are not polluted by the shortcut a previous test left in $TestDrive. - Stop-AtlasProcess: return a real Process from the Get-Process mock so it binds to Stop-Process -InputObject (a pscustomobject fails binding and records 0). - Drop the unused param() blocks from InModuleScope/-Parameters and action mocks that PSScriptAnalyzer flagged as unused parameters.
1 parent 6efc085 commit 2dff5a7

5 files changed

Lines changed: 7 additions & 10 deletions

File tree

tests/Atlas.Registry.Tests.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ Describe 'Copy-AtlasRegistryKeyValues' {
426426

427427
It 'returns silently when the source key is missing' {
428428
InModuleScope Atlas.Registry -Parameters @{ Src = $script:srcSubPath; Dst = $script:dstSubPath } {
429-
param($Src, $Dst)
430429
{ Copy-AtlasRegistryKeyValues -SourceSubPath $Src -DestinationSubPath $Dst } | Should -Not -Throw
431430
}
432431

tests/Atlas.Shortcuts.Tests.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Describe 'New-AtlasShortcut' {
3434
$script:linkDir = Join-Path -Path $TestDrive -ChildPath 'links'
3535
New-Item -Path $script:linkDir -ItemType Directory -Force | Out-Null
3636
$script:destination = Join-Path -Path $script:linkDir -ChildPath 'MyTool.lnk'
37+
Remove-Item -LiteralPath $script:destination -Force -ErrorAction SilentlyContinue
3738
}
3839

3940
It 'creates a .lnk at the destination pointing at the source, defaulting the working dir to the source folder' {

tests/Atlas.Software.Tests.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ Describe 'Assert-AtlasFileHash' {
104104
$hash = (Get-FileHash -LiteralPath $file -Algorithm SHA256).Hash
105105

106106
InModuleScope Atlas.Software -Parameters @{ Path = $file; Hash = $hash } {
107-
param($Path, $Hash)
108107
{ Assert-AtlasFileHash -Path $Path -ExpectedSha256 $Hash -Description 'test file' } | Should -Not -Throw
109108
}
110109
}
@@ -114,7 +113,6 @@ Describe 'Assert-AtlasFileHash' {
114113
Set-Content -LiteralPath $file -Value 'atlas test payload' -NoNewline
115114

116115
InModuleScope Atlas.Software -Parameters @{ Path = $file } {
117-
param($Path)
118116
$wrongHash = 'deadbeef' * 8
119117
{ Assert-AtlasFileHash -Path $Path -ExpectedSha256 $wrongHash -Description 'test file' } |
120118
Should -Throw -ExpectedMessage '*Refusing*'
@@ -271,7 +269,6 @@ Describe 'Remove-AtlasOneDriveUserFolder' {
271269
$folder = Join-Path -Path $TestDrive -ChildPath 'OneDrive-missing'
272270

273271
InModuleScope Atlas.Software -Parameters @{ Path = $folder } {
274-
param($Path)
275272
{ Remove-AtlasOneDriveUserFolder -Path $Path } | Should -Not -Throw
276273
}
277274

tests/Atlas.TasksProcs.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ Describe 'Stop-AtlasProcess' {
6969

7070
It 'force-stops a matching process' {
7171
Mock Get-Process -ModuleName Atlas.TasksProcs -ParameterFilter { $Name -eq 'msteams*' } -MockWith {
72-
[pscustomobject]@{ ProcessName = 'msteams'; Id = 4242 }
72+
[System.Diagnostics.Process]::GetCurrentProcess()
7373
}
7474
Mock Stop-Process -ModuleName Atlas.TasksProcs
7575

7676
Stop-AtlasProcess -Name 'msteams*'
7777

7878
Should -Invoke Stop-Process -ModuleName Atlas.TasksProcs -Times 1 -Exactly -ParameterFilter {
79-
$InputObject.Id -eq 4242 -and $Force
79+
$InputObject.Id -eq $PID -and $Force
8080
}
8181
}
8282

tests/Atlas.Toggles.Tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ Describe 'Invoke-AtlasToggleAction success contract' {
484484
$succeeded = $true
485485
$toggleContext = [pscustomobject]@{ Name = 'T' }
486486

487-
Invoke-AtlasToggleAction -Action { param($Toggle) throw 'deliberate failure' } `
487+
Invoke-AtlasToggleAction -Action { throw 'deliberate failure' } `
488488
-ToggleContext $toggleContext -Succeeded ([ref]$succeeded)
489489

490490
$succeeded | Should -BeFalse
@@ -501,7 +501,7 @@ Describe 'Invoke-AtlasToggleAction success contract' {
501501
$succeeded = $false
502502
$toggleContext = [pscustomobject]@{ Name = 'T' }
503503

504-
Invoke-AtlasToggleAction -Action { param($Toggle) Write-Error 'non-terminating' -ErrorAction Continue } `
504+
Invoke-AtlasToggleAction -Action { Write-Error 'non-terminating' -ErrorAction Continue } `
505505
-ToggleContext $toggleContext -Succeeded ([ref]$succeeded) 2>$null
506506

507507
$succeeded | Should -BeTrue
@@ -517,7 +517,7 @@ Describe 'Invoke-AtlasToggleAction success contract' {
517517
$succeeded = $false
518518
$toggleContext = [pscustomobject]@{ Name = 'T' }
519519

520-
Invoke-AtlasToggleAction -Action { param($Toggle) } `
520+
Invoke-AtlasToggleAction -Action { } `
521521
-ToggleContext $toggleContext -Succeeded ([ref]$succeeded)
522522

523523
$succeeded | Should -BeTrue
@@ -533,7 +533,7 @@ Describe 'Invoke-AtlasToggleAction success contract' {
533533
$succeeded = $false
534534
$toggleContext = [pscustomobject]@{ Name = 'T' }
535535

536-
$observedPreference = Invoke-AtlasToggleAction -Action { param($Toggle) [string]$ErrorActionPreference } `
536+
$observedPreference = Invoke-AtlasToggleAction -Action { [string]$ErrorActionPreference } `
537537
-ToggleContext $toggleContext -Succeeded ([ref]$succeeded)
538538

539539
$observedPreference | Should -Be 'Continue'

0 commit comments

Comments
 (0)