Skip to content

Commit 38e3708

Browse files
author
Kapil Borle
committed
Add test to check SaveDscResourceDependency parameter
1 parent 5081eda commit 38e3708

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

Tests/Engine/InvokeScriptAnalyzer.tests.ps1

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Describe "Test available parameters" {
1919
It "has a Path parameter" {
2020
$params.ContainsKey("Path") | Should Be $true
2121
}
22-
22+
2323
It "accepts string" {
2424
$params["Path"].ParameterType.FullName | Should Be "System.String"
2525
}
@@ -29,8 +29,8 @@ Describe "Test available parameters" {
2929
It "has a ScriptDefinition parameter" {
3030
$params.ContainsKey("ScriptDefinition") | Should Be $true
3131
}
32-
33-
It "accepts string" {
32+
33+
It "accepts string" {
3434
$params["ScriptDefinition"].ParameterType.FullName | Should Be "System.String"
3535
}
3636
}
@@ -69,6 +69,16 @@ Describe "Test available parameters" {
6969
}
7070
}
7171

72+
Context "SaveDSCResourceDependency parameter" {
73+
It "has the parameter" {
74+
$params.ContainsKey("SaveDscResourceDependency") | Should Be $true
75+
}
76+
77+
It "is a switch parameter" {
78+
$params["SaveDscResourceDependency"].ParameterType.FullName | Should Be "System.Management.Automation.SwitchParameter"
79+
}
80+
}
81+
7282
Context "It has 2 parameter sets: File and ScriptDefinition" {
7383
It "Has 2 parameter sets" {
7484
$sa.ParameterSets.Count | Should Be 2
@@ -144,14 +154,14 @@ Describe "Test Path" {
144154
if (!$testingLibraryUsage)
145155
{
146156
#There is probably a more concise way to do this but for now we will settle for this!
147-
Function GetFreeDrive ($freeDriveLen) {
157+
Function GetFreeDrive ($freeDriveLen) {
148158
$ordA = 65
149159
$ordZ = 90
150160
$freeDrive = ""
151161
$freeDriveName = ""
152162
do{
153163
$freeDriveName = (1..$freeDriveLen | %{[char](Get-Random -Maximum $ordZ -Minimum $ordA)}) -join ''
154-
$freeDrive = $freeDriveName + ":"
164+
$freeDrive = $freeDriveName + ":"
155165
}while(Test-Path $freeDrive)
156166
$freeDrive, $freeDriveName
157167
}
@@ -180,7 +190,7 @@ Describe "Test Path" {
180190
Context "When given a directory" {
181191
$withoutPathWithDirectory = Invoke-ScriptAnalyzer -Recurse $directory\RecursionDirectoryTest
182192
$withPathWithDirectory = Invoke-ScriptAnalyzer -Recurse -Path $directory\RecursionDirectoryTest
183-
193+
184194
It "Has the same count as without Path parameter"{
185195
$withoutPathWithDirectory.Count -eq $withPathWithDirectory.Count | Should Be $true
186196
}
@@ -206,7 +216,7 @@ Describe "Test ExcludeRule" {
206216

207217
It "excludes 3 rules" {
208218
$noViolations = Invoke-ScriptAnalyzer $directory\..\Rules\BadCmdlet.ps1 -ExcludeRule $rules | Where-Object {$rules -contains $_.RuleName}
209-
$noViolations.Count | Should Be 0
219+
$noViolations.Count | Should Be 0
210220
}
211221
}
212222

@@ -329,23 +339,23 @@ Describe "Test CustomizedRulePath" {
329339
It "When supplied with a collection of paths" {
330340
$customizedRulePath = Invoke-ScriptAnalyzer $directory\TestScript.ps1 -CustomRulePath ("$directory\CommunityAnalyzerRules", "$directory\SampleRule", "$directory\SampleRule\SampleRule2")
331341
$customizedRulePath.Count | Should Be 3
332-
}
342+
}
333343

334344
}
335345

336346

337347
Context "When used incorrectly" {
338-
It "file cannot be found" {
348+
It "file cannot be found" {
339349
try
340350
{
341351
Invoke-ScriptAnalyzer $directory\TestScript.ps1 -CustomRulePath "Invalid CustomRulePath"
342352
}
343353
catch
344354
{
345355
if (-not $testingLibraryUsage)
346-
{
347-
$Error[0].FullyQualifiedErrorId | should match "PathNotFound,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand"
348-
}
356+
{
357+
$Error[0].FullyQualifiedErrorId | should match "PathNotFound,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand"
358+
}
349359
}
350360
}
351361
}

Tests/Engine/ModuleDependencyHandler.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Describe "Resolve DSC Resource Dependency" {
105105
}
106106
}
107107

108-
Context "Invoke-ScriptAnalyzer with switch" {
108+
Context "Invoke-ScriptAnalyzer without switch but with module in temp path" {
109109
$oldEnvVars = Get-Item Env:\* | Sort-Object -Property Key
110110
$moduleName = "MyDscResource"
111111
$modulePath = Join-Path (Join-Path (Join-Path (Split-Path $directory) "Rules") "DSCResources") $moduleName

0 commit comments

Comments
 (0)