@@ -52,10 +52,26 @@ function SetupTestRepos {
5252
5353Describe " DSC resource schema tests" - tags ' CI' {
5454 BeforeAll {
55+
56+ $skipTest = $null -eq (Get-Command - Type Application - Name pwsh - ErrorAction SilentlyContinue)
57+
58+ if ($skipTest ) {
59+ $originalDefaultParameterValues = $PSDefaultParameterValues.Clone ()
60+ $PSDefaultParameterValues [' it:skip' ] = $skipTest
61+ return
62+ }
63+
5564 SetupDsc
5665 }
5766
58- It ' DSC v3 resources can be found' {
67+ AfterAll {
68+ if ($skipTest ) {
69+ $global :PSDefaultParameterValues = $originalDefaultParameterValues
70+ }
71+ }
72+
73+ It ' DSC v3 resources can be found' - Skip:$skipTest {
74+
5975 $repoResource = & $script :dscExe resource list Microsoft.PowerShell.PSResourceGet/ Repository - o json | convertfrom-json | select-object - ExpandProperty type
6076 $repoResource | Should - BeExactly ' Microsoft.PowerShell.PSResourceGet/Repository'
6177
@@ -86,12 +102,26 @@ Describe "DSC resource schema tests" -tags 'CI' {
86102
87103Describe ' Repository Resource Tests' - Tags ' CI' {
88104 BeforeAll {
105+ $skipTest = $null -eq (Get-Command - Type Application - Name pwsh - ErrorAction SilentlyContinue)
106+
107+ if ($skipTest ) {
108+ $originalDefaultParameterValues = $PSDefaultParameterValues.Clone ()
109+ $PSDefaultParameterValues [' it:skip' ] = $skipTest
110+ return
111+ }
112+
89113 # Register a test repository to ensure DSC can access repositories
90114 Register-PSResourceRepository - Name ' TestRepo' - uri ' https://www.doesnotexist.com' - ErrorAction SilentlyContinue - APIVersion Local
91115 }
92116 AfterAll {
117+ if ($skipTest ) {
118+ $global :PSDefaultParameterValues = $originalDefaultParameterValues
119+ return
120+ }
121+
93122 # Clean up the test repository
94123 Unregister-PSResourceRepository - Name ' TestRepo' - ErrorAction SilentlyContinue
124+
95125 }
96126
97127 It ' Can get a Repository resource instance' {
@@ -173,10 +203,24 @@ Describe 'Repository Resource Tests' -Tags 'CI' {
173203
174204Describe " PSResourceList Resource Tests" - Tags ' CI' {
175205 BeforeAll {
206+
207+ $skipTest = $null -eq (Get-Command - Type Application - Name pwsh - ErrorAction SilentlyContinue)
208+
209+ if ($skipTest ) {
210+ $originalDefaultParameterValues = $PSDefaultParameterValues.Clone ()
211+ $PSDefaultParameterValues [' it:skip' ] = $skipTest
212+ return
213+ }
214+
176215 SetupDsc
177216 SetupTestRepos
178217 }
179218 AfterAll {
219+ if ($skipTest ) {
220+ $PSDefaultParameterValues = $originalDefaultParameterValues
221+ return
222+ }
223+
180224 # Clean up the test repository
181225 Get-RevertPSResourceRepositoryFile
182226 }
@@ -254,7 +298,7 @@ Describe "PSResourceList Resource Tests" -Tags 'CI' {
254298 }
255299
256300 It ' Set operation stdout contains only valid JSON and is not contaminated by warning messages' {
257- # Simple regression test as it is hard to predict a warning message but we want to ensure they do not break DSC's JSON parsing. This test does not verify that warnings are emitted when expected,
301+ # Simple regression test as it is hard to predict a warning message but we want to ensure they do not break DSC's JSON parsing. This test does not verify that warnings are emitted when expected,
258302 # only that if they are emitted they do not reach stdout.
259303 Uninstall-PSResource - Name $script :testModuleName - ErrorAction SilentlyContinue
260304
@@ -330,9 +374,23 @@ Describe "PSResourceList Resource Tests" -Tags 'CI' {
330374
331375Describe ' E2E tests for Repository resource' - Tags ' CI' {
332376 BeforeAll {
377+ $skipTest = $null -eq (Get-Command - Type Application - Name pwsh - ErrorAction SilentlyContinue)
378+
379+ if ($skipTest ) {
380+ $originalDefaultParameterValues = $PSDefaultParameterValues.Clone ()
381+ $PSDefaultParameterValues [' it:skip' ] = $skipTest
382+ return
383+ }
384+
333385 Get-PSResourceRepository - Name ' TestRepository' - ErrorAction SilentlyContinue | Unregister-PSResourceRepository - ErrorAction SilentlyContinue
334386 }
335387
388+ AfterAll {
389+ if ($skipTest ) {
390+ $PSDefaultParameterValues = $originalDefaultParameterValues
391+ }
392+ }
393+
336394 It ' Register test repository via DSC configuration' {
337395 $configPath = Join-Path - Path $PSScriptRoot - ChildPath ' configs/repository.get.dsc.yaml'
338396 & $dscExe config set -f $configPath
@@ -377,6 +435,14 @@ Describe 'E2E tests for Repository resource' -Tags 'CI' {
377435
378436Describe ' E2E tests for PSResourceList resource' - Tags ' CI' {
379437 BeforeAll {
438+ $skipTest = $null -eq (Get-Command - Type Application - Name pwsh - ErrorAction SilentlyContinue)
439+
440+ if ($skipTest ) {
441+ $originalDefaultParameterValues = $PSDefaultParameterValues.Clone ()
442+ $PSDefaultParameterValues [' it:skip' ] = $skipTest
443+ return
444+ }
445+
380446 SetupDsc
381447
382448 # # The installed modules will not be found in the Windows PowerShell module path because DSC will install them in the PowerShell 7 context.
@@ -493,6 +559,14 @@ Describe 'E2E tests for PSResourceList resource' -Tags 'CI' {
493559Describe " Error code tests" - Tags ' CI' {
494560
495561 BeforeAll {
562+ $skipTest = $null -eq (Get-Command - Type Application - Name pwsh - ErrorAction SilentlyContinue)
563+
564+ if ($skipTest ) {
565+ $originalDefaultParameterValues = $PSDefaultParameterValues.Clone ()
566+ $PSDefaultParameterValues [' it:skip' ] = $skipTest
567+ return
568+ }
569+
496570 SetupDsc
497571
498572 $mod = Get-PSResource - Name ' testmodule99' - ErrorAction SilentlyContinue
@@ -501,6 +575,12 @@ Describe "Error code tests" -Tags 'CI' {
501575 }
502576 }
503577
578+ AfterAll {
579+ if ($skipTest ) {
580+ $PSDefaultParameterValues = $originalDefaultParameterValues
581+ }
582+ }
583+
504584 It ' Repository not found should return error code 2' {
505585 $out = & $script :dscExe config set -f (Join-Path - Path $PSScriptRoot - ChildPath ' configs/psresourcegetlist.error.norepo.dsc.yaml' ) 2>&1
506586 $out [-1 ] | Should - BeLike " *Repository not found (during set operation)*"
0 commit comments