4
4
Describe ' tests for resource discovery' {
5
5
BeforeAll {
6
6
$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
+ }
7
13
}
8
14
9
15
AfterEach {
@@ -98,32 +104,23 @@ Describe 'tests for resource discovery' {
98
104
}
99
105
100
106
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
- }
106
107
107
108
# 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
110
111
111
112
# perform List on an adapter - this should create adapter lookup table file
112
113
dsc resource list - a Microsoft.DSC/ PowerShell | Out-Null
113
114
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'
115
117
}
116
118
117
119
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
- }
123
120
124
121
# 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
127
124
128
125
# perform Get on an adapter - this should create adapter lookup table file
129
126
$oldPSModulePath = $env: PSModulePath
@@ -132,7 +129,8 @@ Describe 'tests for resource discovery' {
132
129
$env: PSModulePath += [System.IO.Path ]::PathSeparator + $TestClassResourcePath
133
130
" {'Name':'TestClassResource1'}" | dsc resource get - r ' TestClassResource/TestClassResource' | Out-Null
134
131
135
- Test-Path $lookupTableFilePath - PathType Leaf | Should - BeTrue
132
+ Test-Path $script :lookupTableFilePath - PathType Leaf | Should - BeTrue
133
+ $script :lookupTableFilePath | Should - FileContentMatchExactly " TestClassResource/TestClassResource"
136
134
$env: PSModulePath = $oldPSModulePath
137
135
}
138
136
0 commit comments