Skip to content

Commit 9fcfadc

Browse files
author
Kapil Borle
committed
Add test cases to no violations file
1 parent 7556149 commit 9fcfadc

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

Tests/Rules/AvoidUsingComputerNameHardcoded.tests.ps1

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,4 @@ Describe "AvoidUsingComputerNameHardcoded" {
2222
$noViolations.Count | Should Be 0
2323
}
2424
}
25-
26-
Context "When the argument refers to localhost" {
27-
$testCases = @(
28-
@{ localhostName = 'localhost' },
29-
@{ localhostName = '127.0.0.1' },
30-
@{ localhostName = '::1' }
31-
)
32-
33-
It "returns no violation for <localhostName>" -TestCases $testCases {
34-
param($localhostName)
35-
$params = @{
36-
ScriptDefinition = "Invoke-Command -ComputerName $localhostName"
37-
IncludeRule = $violationName
38-
}
39-
40-
$violations = Invoke-ScriptAnalyzer @params
41-
$violations.Count | Should Be 0
42-
}
43-
}
4425
}

Tests/Rules/AvoidUsingComputerNameHardcodedNoViolations.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ Invoke-Command -ComputerName 127.0.0.1
77
Invoke-Command -ComputerName:'localhost'
88
Invoke-Command -ComputerName:"."
99
Invoke-Command -ComputerName:'::1'
10-
Invoke-Command -ComputerName:"127.0.0.1"
10+
Invoke-Command -ComputerName:"127.0.0.1"
11+
Invoke-Command -ComputerName "localhost"
12+
Invoke-Command -ComputerName "."
13+
Invoke-Command -ComputerName "::1"
14+
Invoke-Command -ComputerName "127.0.0.1"

0 commit comments

Comments
 (0)