Skip to content

Commit 28dd171

Browse files
author
Andrew
committed
test update 1
1 parent 0bf2373 commit 28dd171

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

dsc/tests/dsc_discovery.tests.ps1

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
Describe 'tests for resource discovery' {
55
BeforeAll {
66
$env:DSC_RESOURCE_PATH = $testdrive
7+
8+
$script:lookupTableFilePath = if ($IsWindows) {
9+
Join-Path $env:LocalAppData "dsc\AdaptedResourcesLookupTable.json"
10+
} else {
11+
Join-Path $env:HOME ".dsc" "AdaptedResourcesLookupTable.json"
12+
}
713
}
814

915
AfterEach {
@@ -98,32 +104,23 @@ Describe 'tests for resource discovery' {
98104
}
99105

100106
It 'Ensure List operation populates adapter lookup table' {
101-
$lookupTableFilePath = if ($IsWindows) {
102-
Join-Path $env:LocalAppData "dsc\AdaptedResourcesLookupTable.json"
103-
} else {
104-
Join-Path $env:HOME ".dsc" "AdaptedResourcesLookupTable.json"
105-
}
106107

107108
# remove adapter lookup table file
108-
Remove-Item -Force -Path $lookupTableFilePath -ErrorAction SilentlyContinue
109-
Test-Path $lookupTableFilePath -PathType Leaf | Should -BeFalse
109+
Remove-Item -Force -Path $script:lookupTableFilePath -ErrorAction SilentlyContinue
110+
Test-Path $script:lookupTableFilePath -PathType Leaf | Should -BeFalse
110111

111112
# perform List on an adapter - this should create adapter lookup table file
112113
dsc resource list -a Microsoft.DSC/PowerShell | Out-Null
113114

114-
Test-Path $lookupTableFilePath -PathType Leaf | Should -BeTrue
115+
Test-Path $script:lookupTableFilePath -PathType Leaf | Should -BeTrue
116+
$script:lookupTableFilePath | Should -FileContentMatchExactly 'Microsoft.DSC/PowerShell'
115117
}
116118

117119
It 'Ensure non-List operation populates adapter lookup table' {
118-
$lookupTableFilePath = if ($IsWindows) {
119-
Join-Path $env:LocalAppData "dsc\AdaptedResourcesLookupTable.json"
120-
} else {
121-
Join-Path $env:HOME ".dsc" "AdaptedResourcesLookupTable.json"
122-
}
123120

124121
# remove adapter lookup table file
125-
Remove-Item -Force -Path $lookupTableFilePath -ErrorAction SilentlyContinue
126-
Test-Path $lookupTableFilePath -PathType Leaf | Should -BeFalse
122+
Remove-Item -Force -Path $script:lookupTableFilePath -ErrorAction SilentlyContinue
123+
Test-Path $script:lookupTableFilePath -PathType Leaf | Should -BeFalse
127124

128125
# perform Get on an adapter - this should create adapter lookup table file
129126
$oldPSModulePath = $env:PSModulePath
@@ -132,7 +129,8 @@ Describe 'tests for resource discovery' {
132129
$env:PSModulePath += [System.IO.Path]::PathSeparator + $TestClassResourcePath
133130
"{'Name':'TestClassResource1'}" | dsc resource get -r 'TestClassResource/TestClassResource' | Out-Null
134131

135-
Test-Path $lookupTableFilePath -PathType Leaf | Should -BeTrue
132+
Test-Path $script:lookupTableFilePath -PathType Leaf | Should -BeTrue
133+
$script:lookupTableFilePath | Should -FileContentMatchExactly "TestClassResource/TestClassResource"
136134
$env:PSModulePath = $oldPSModulePath
137135
}
138136

0 commit comments

Comments
 (0)