Tests: Fix PSSA (#27)

* Tests: fix indent/align (with Visual Formatter Code)

* Tests: Suppress warning about use ConvertToSecureString...

* Setup(Tests): fix PSSA about unused variable
This commit is contained in:
Alexis La Goutte 2021-09-10 17:38:00 +02:00 committed by GitHub
parent a608d6ebd7
commit 7edbae953f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 80 additions and 52 deletions

View file

@ -11,6 +11,10 @@
DCIM tests.
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
param
(
)
Import-Module Pester
Remove-Module NetboxPS -Force -ErrorAction SilentlyContinue

View file

@ -11,6 +11,10 @@
A description of the file.
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
param
(
)
Import-Module Pester
Remove-Module NetboxPS -Force -ErrorAction SilentlyContinue

View file

@ -11,6 +11,10 @@
A description of the file.
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
param
(
)
Import-Module Pester
Remove-Module NetboxPS -Force -ErrorAction SilentlyContinue

View file

@ -11,6 +11,10 @@
Helper functions Pester tests
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
param
(
)
Import-Module Pester
Remove-Module NetboxPS -Force -ErrorAction SilentlyContinue
@ -88,7 +92,7 @@ Describe "Helpers tests" -Tag 'Core', 'Helpers' -Fixture {
Context -Name "Building URI components" -Fixture {
It "Should give a basic hashtable" {
$URIComponents = BuildURIComponents -URISegments @('segment1', 'segment2') -ParametersDictionary @{'param1' = 1}
$URIComponents = BuildURIComponents -URISegments @('segment1', 'segment2') -ParametersDictionary @{'param1' = 1 }
$URIComponents | Should -BeOfType [hashtable]
$URIComponents.Keys.Count | Should -BeExactly 2
@ -100,7 +104,7 @@ Describe "Helpers tests" -Tag 'Core', 'Helpers' -Fixture {
}
It "Should add a single ID parameter to the segments" {
$URIComponents = BuildURIComponents -URISegments @('segment1', 'segment2') -ParametersDictionary @{'id' = 123}
$URIComponents = BuildURIComponents -URISegments @('segment1', 'segment2') -ParametersDictionary @{'id' = 123 }
$URIComponents | Should -BeOfType [hashtable]
$URIComponents.Keys.Count | Should -BeExactly 2
@ -111,7 +115,7 @@ Describe "Helpers tests" -Tag 'Core', 'Helpers' -Fixture {
}
It "Should add multiple IDs to the parameters id__in" {
$URIComponents = BuildURIComponents -URISegments @('segment1', 'segment2') -ParametersDictionary @{'id' = "123", "456"}
$URIComponents = BuildURIComponents -URISegments @('segment1', 'segment2') -ParametersDictionary @{'id' = "123", "456" }
$URIComponents | Should -BeOfType [hashtable]
$URIComponents.Keys.Count | Should -BeExactly 2
@ -123,7 +127,7 @@ Describe "Helpers tests" -Tag 'Core', 'Helpers' -Fixture {
}
It "Should skip a particular parameter name" {
$URIComponents = BuildURIComponents -URISegments @('segment1', 'segment2') -ParametersDictionary @{'param1' = 1; 'param2' = 2} -SkipParameterByName 'param2'
$URIComponents = BuildURIComponents -URISegments @('segment1', 'segment2') -ParametersDictionary @{'param1' = 1; 'param2' = 2 } -SkipParameterByName 'param2'
$URIComponents | Should -BeOfType [hashtable]
$URIComponents.Keys.Count | Should -BeExactly 2
@ -136,7 +140,7 @@ Describe "Helpers tests" -Tag 'Core', 'Helpers' -Fixture {
}
It "Should add a query (q) parameter" {
$URIComponents = BuildURIComponents -URISegments @('segment1', 'segment2') -ParametersDictionary @{'query' = 'mytestquery'}
$URIComponents = BuildURIComponents -URISegments @('segment1', 'segment2') -ParametersDictionary @{'query' = 'mytestquery' }
$URIComponents | Should -BeOfType [hashtable]
$URIComponents.Keys.Count | Should -BeExactly 2

View file

@ -11,6 +11,10 @@
IPAM Pester tests
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
param
(
)
Import-Module Pester
Remove-Module NetboxPS -Force -ErrorAction SilentlyContinue

View file

@ -11,6 +11,10 @@
Setup function Pester tests
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
param
(
)
Import-Module Pester
Remove-Module NetboxPS -Force -ErrorAction SilentlyContinue
@ -43,7 +47,7 @@ Describe "Setup tests" -Tag 'Core', 'Setup' -Fixture {
}
It "Checks the set credentials" {
$Creds = Set-NetboxCredential -Token (ConvertTo-SecureString -String "faketoken" -Force -AsPlainText)
Set-NetboxCredential -Token (ConvertTo-SecureString -String "faketoken" -Force -AsPlainText)
(Get-NetboxCredential).GetNetworkCredential().Password | Should -BeExactly "faketoken"
}
}

View file

@ -11,6 +11,10 @@
Virtualization Pester tests
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
param
(
)
Import-Module Pester
Remove-Module NetboxPS -Force -ErrorAction SilentlyContinue