Skip to content

Commit ca3ab8f

Browse files
Fix PSScriptAnalyzer issues in test file
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
1 parent f19cfc8 commit ca3ab8f

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tests/PowerShellGallery.Tests.ps1

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
Describe 'PowerShellGallery' {
1+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
2+
'PSAvoidUsingConvertToSecureStringWithPlainText', '',
3+
Justification = 'Test file - converting test data to SecureString for testing purposes only.'
4+
)]
5+
param()
6+
7+
Describe 'PowerShellGallery' {
28
Context 'Function: Get-PSGalleryAPI' {
39
It 'Should not throw' {
410
{ Get-PSGalleryAPI } | Should -Not -Throw
@@ -27,7 +33,7 @@
2733
try {
2834
$null = Disconnect-PowerShellGallery -Name $script:TestContextName -Confirm:$false -ErrorAction SilentlyContinue
2935
} catch {
30-
# Ignore cleanup errors
36+
Write-Verbose "Cleanup error ignored: $_"
3137
}
3238
}
3339

@@ -66,7 +72,7 @@
6672
try {
6773
$null = Disconnect-PowerShellGallery -Name $script:GetTestContextName -Confirm:$false -ErrorAction SilentlyContinue
6874
} catch {
69-
# Ignore cleanup errors
75+
Write-Verbose "Cleanup error ignored: $_"
7076
}
7177
}
7278

@@ -95,10 +101,10 @@
95101
$testContextName2 = 'SwitchTestContext2_' + (Get-Random)
96102
$script:SwitchTestContextName1 = $testContextName1
97103
$script:SwitchTestContextName2 = $testContextName2
98-
104+
99105
$secureApiKey1 = ConvertTo-SecureString -String 'test-switch-api-key-1' -AsPlainText -Force
100106
$secureApiKey2 = ConvertTo-SecureString -String 'test-switch-api-key-2' -AsPlainText -Force
101-
107+
102108
Connect-PowerShellGallery -Name $testContextName1 -ApiKey $secureApiKey1 -Silent
103109
Connect-PowerShellGallery -Name $testContextName2 -ApiKey $secureApiKey2 -Silent
104110
}
@@ -109,7 +115,7 @@
109115
$null = Disconnect-PowerShellGallery -Name $script:SwitchTestContextName1 -Confirm:$false -ErrorAction SilentlyContinue
110116
$null = Disconnect-PowerShellGallery -Name $script:SwitchTestContextName2 -Confirm:$false -ErrorAction SilentlyContinue
111117
} catch {
112-
# Ignore cleanup errors
118+
Write-Verbose "Cleanup error ignored: $_"
113119
}
114120
}
115121

@@ -159,7 +165,7 @@
159165
try {
160166
$null = Disconnect-PowerShellGallery -Name $script:TokenTestContextName -Confirm:$false -ErrorAction SilentlyContinue
161167
} catch {
162-
# Ignore cleanup errors
168+
Write-Verbose "Cleanup error ignored: $_"
163169
}
164170
}
165171

@@ -191,7 +197,7 @@
191197
try {
192198
$null = Disconnect-PowerShellGallery -Name $script:AccessTestContextName -Confirm:$false -ErrorAction SilentlyContinue
193199
} catch {
194-
# Ignore cleanup errors
200+
Write-Verbose "Cleanup error ignored: $_"
195201
}
196202
}
197203

0 commit comments

Comments
 (0)