Skip to content

Commit 1572460

Browse files
authored
Merge pull request #432 from anmenaga/ps_cache
Added DscResourceCache
2 parents ab558d4 + 81d27f7 commit 1572460

File tree

3 files changed

+227
-104
lines changed

3 files changed

+227
-104
lines changed

powershell-adapter/Tests/powershellgroup.config.tests.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,25 @@ Describe 'PowerShell adapter resource tests' {
1111
$env:PSModulePath += [System.IO.Path]::PathSeparator + $PSScriptRoot
1212
$pwshConfigPath = Join-path $PSScriptRoot "class_ps_resources.dsc.yaml"
1313
$winpsConfigPath = Join-path $PSScriptRoot "winps_resource.dsc.yaml"
14+
15+
if ($IsLinux -or $IsMacOS) {
16+
$cacheFilePath = Join-Path $env:HOME ".dsc" "PSAdapterCache.json"
17+
}
18+
else
19+
{
20+
$cacheFilePath = Join-Path $env:LocalAppData "dsc" "PSAdapterCache.json"
21+
$cacheFilePath_v5 = Join-Path $env:LocalAppData "dsc" "WindowsPSAdapterCache.json"
22+
}
1423
}
1524
AfterAll {
1625
$env:PSModulePath = $OldPSModulePath
1726
}
1827

28+
BeforeEach {
29+
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath
30+
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath_v5
31+
}
32+
1933
It 'Get works on config with class-based and script-based resources' -Skip:(!$IsWindows){
2034

2135
$r = Get-Content -Raw $pwshConfigPath | dsc config get

powershell-adapter/Tests/powershellgroup.resource.tests.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,25 @@ Describe 'PowerShell adapter resource tests' {
99
}
1010
$OldPSModulePath = $env:PSModulePath
1111
$env:PSModulePath += [System.IO.Path]::PathSeparator + $PSScriptRoot
12+
13+
if ($IsLinux -or $IsMacOS) {
14+
$cacheFilePath = Join-Path $env:HOME ".dsc" "PSAdapterCache.json"
15+
}
16+
else
17+
{
18+
$cacheFilePath = Join-Path $env:LocalAppData "dsc" "PSAdapterCache.json"
19+
$cacheFilePath_v5 = Join-Path $env:LocalAppData "dsc" "WindowsPSAdapterCache.json"
20+
}
1221
}
1322
AfterAll {
1423
$env:PSModulePath = $OldPSModulePath
1524
}
1625

26+
BeforeEach {
27+
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath
28+
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath_v5
29+
}
30+
1731
It 'Discovery includes class-based and script-based resources ' -Skip:(!$IsWindows){
1832

1933
$r = dsc resource list * -a Microsoft.DSC/PowerShell

0 commit comments

Comments
 (0)