Fix: Use direct env check for -Skip (Pester evaluates before BeforeAll)

This commit is contained in:
NexusOne23 2025-12-09 06:02:13 +01:00
parent 745d808771
commit 75c6c76ba2
8 changed files with 22 additions and 30 deletions

View file

@ -2,7 +2,6 @@ Describe "AdvancedSecurity Integration Tests" {
BeforeAll {
$script:ModulePath = Join-Path $PSScriptRoot "..\..\Modules\AdvancedSecurity"
$script:ManifestPath = Join-Path $script:ModulePath "AdvancedSecurity.psd1"
$script:IsCI = $env:GITHUB_ACTIONS -eq 'true' -or $env:CI -eq 'true'
}
Context "Module Structure" {
@ -48,24 +47,24 @@ Describe "AdvancedSecurity Integration Tests" {
}
Context "DryRun Execution" {
It "Should run Invoke-AdvancedSecurity in DryRun mode without errors" -Skip:$script:IsCI {
It "Should run Invoke-AdvancedSecurity in DryRun mode without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
# Skip on CI - requires admin rights and registry access
{ Invoke-AdvancedSecurity -DryRun -ErrorAction Stop } | Should -Not -Throw
}
It "Should run with Balanced profile in DryRun mode" -Skip:$script:IsCI {
It "Should run with Balanced profile in DryRun mode" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
{ Invoke-AdvancedSecurity -SecurityProfile "Balanced" -DryRun -ErrorAction Stop } | Should -Not -Throw
}
It "Should run with Enterprise profile in DryRun mode" -Skip:$script:IsCI {
It "Should run with Enterprise profile in DryRun mode" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
{ Invoke-AdvancedSecurity -SecurityProfile "Enterprise" -DryRun -ErrorAction Stop } | Should -Not -Throw
}
It "Should run with Maximum profile in DryRun mode" -Skip:$script:IsCI {
It "Should run with Maximum profile in DryRun mode" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
{ Invoke-AdvancedSecurity -SecurityProfile "Maximum" -DryRun -ErrorAction Stop } | Should -Not -Throw
}
It "Should run Test-AdvancedSecurity without errors" -Skip:$script:IsCI {
It "Should run Test-AdvancedSecurity without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
{ Test-AdvancedSecurity -ErrorAction Stop } | Should -Not -Throw
}
}