Skip to content

Commit

Permalink
Merge pull request #432 from anmenaga/ps_cache
Browse files Browse the repository at this point in the history
Added DscResourceCache
  • Loading branch information
SteveL-MSFT committed May 16, 2024
2 parents ab558d4 + 81d27f7 commit 1572460
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 104 deletions.
14 changes: 14 additions & 0 deletions powershell-adapter/Tests/powershellgroup.config.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@ Describe 'PowerShell adapter resource tests' {
$env:PSModulePath += [System.IO.Path]::PathSeparator + $PSScriptRoot
$pwshConfigPath = Join-path $PSScriptRoot "class_ps_resources.dsc.yaml"
$winpsConfigPath = Join-path $PSScriptRoot "winps_resource.dsc.yaml"

if ($IsLinux -or $IsMacOS) {
$cacheFilePath = Join-Path $env:HOME ".dsc" "PSAdapterCache.json"
}
else
{
$cacheFilePath = Join-Path $env:LocalAppData "dsc" "PSAdapterCache.json"
$cacheFilePath_v5 = Join-Path $env:LocalAppData "dsc" "WindowsPSAdapterCache.json"
}
}
AfterAll {
$env:PSModulePath = $OldPSModulePath
}

BeforeEach {
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath_v5
}

It 'Get works on config with class-based and script-based resources' -Skip:(!$IsWindows){

$r = Get-Content -Raw $pwshConfigPath | dsc config get
Expand Down
14 changes: 14 additions & 0 deletions powershell-adapter/Tests/powershellgroup.resource.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,25 @@ Describe 'PowerShell adapter resource tests' {
}
$OldPSModulePath = $env:PSModulePath
$env:PSModulePath += [System.IO.Path]::PathSeparator + $PSScriptRoot

if ($IsLinux -or $IsMacOS) {
$cacheFilePath = Join-Path $env:HOME ".dsc" "PSAdapterCache.json"
}
else
{
$cacheFilePath = Join-Path $env:LocalAppData "dsc" "PSAdapterCache.json"
$cacheFilePath_v5 = Join-Path $env:LocalAppData "dsc" "WindowsPSAdapterCache.json"
}
}
AfterAll {
$env:PSModulePath = $OldPSModulePath
}

BeforeEach {
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath_v5
}

It 'Discovery includes class-based and script-based resources ' -Skip:(!$IsWindows){

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

0 comments on commit 1572460

Please sign in to comment.