File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -280,4 +280,31 @@ Describe 'PowerShell adapter resource tests' {
280
280
281
281
$env: TestClassResourceResultCount = $null
282
282
}
283
+
284
+ It ' Verify that there are no cache rebuids for several sequential executions' {
285
+
286
+ # remove cache file
287
+ $cacheFilePath = if ($IsWindows ) {
288
+ # PS 6+ on Windows
289
+ Join-Path $env: LocalAppData " dsc\PSAdapterCache.json"
290
+ } else {
291
+ # either WinPS or PS 6+ on Linux/Mac
292
+ if ($PSVersionTable.PSVersion.Major -le 5 ) {
293
+ Join-Path $env: LocalAppData " dsc\WindowsPSAdapterCache.json"
294
+ } else {
295
+ Join-Path $env: HOME " .dsc" " PSAdapterCache.json"
296
+ }
297
+ }
298
+ Remove-Item - Force - Path $cacheFilePath - ErrorAction SilentlyContinue
299
+
300
+ # first execution should build the cache
301
+ dsc - l trace resource list - a Microsoft.DSC/ PowerShell 2> $TestDrive / tracing.txt
302
+ " $TestDrive /tracing.txt" | Should - FileContentMatchExactly ' Constructing Get-DscResource cache'
303
+
304
+ # next executions following shortly after should Not rebuild the cache
305
+ 1 .. 3 | % {
306
+ dsc - l trace resource list - a Microsoft.DSC/ PowerShell 2> $TestDrive / tracing.txt
307
+ " $TestDrive /tracing.txt" | Should -Not - FileContentMatchExactly ' Constructing Get-DscResource cache'
308
+ }
309
+ }
283
310
}
Original file line number Diff line number Diff line change @@ -70,4 +70,21 @@ Describe 'WindowsPowerShell adapter resource tests' {
70
70
$res = $r | ConvertFrom-Json
71
71
$res.results [0 ].result.actualState.result[0 ].properties.DestinationPath | Should - Be " $testFile "
72
72
}
73
+
74
+ It ' Verify that there are no cache rebuids for several sequential executions' {
75
+
76
+ # remove cache file
77
+ $cacheFilePath = Join-Path $env: LocalAppData " dsc\WindowsPSAdapterCache.json"
78
+ Remove-Item - Force - Path $cacheFilePath - ErrorAction SilentlyContinue
79
+
80
+ # first execution should build the cache
81
+ dsc - l trace resource list - a Microsoft.Windows/ WindowsPowerShell 2> $TestDrive / tracing.txt
82
+ " $TestDrive /tracing.txt" | Should - FileContentMatchExactly ' Constructing Get-DscResource cache'
83
+
84
+ # next executions following shortly after should Not rebuild the cache
85
+ 1 .. 3 | % {
86
+ dsc - l trace resource list - a Microsoft.Windows/ WindowsPowerShell 2> $TestDrive / tracing.txt
87
+ " $TestDrive /tracing.txt" | Should -Not - FileContentMatchExactly ' Constructing Get-DscResource cache'
88
+ }
89
+ }
73
90
}
You can’t perform that action at this time.
0 commit comments