From efa89c4b74f3fce2052a10bc20155ae54a6d68d3 Mon Sep 17 00:00:00 2001 From: James Garriss <52328727+james-garriss@users.noreply.github.com> Date: Fri, 22 Nov 2024 08:31:16 -0500 Subject: [PATCH] Split back into 2 describes --- Testing/workflow/Invoke-PSSA.Tests.ps1 | 43 ++++++++++---------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/Testing/workflow/Invoke-PSSA.Tests.ps1 b/Testing/workflow/Invoke-PSSA.Tests.ps1 index 8cd1df2b1..d30265cd2 100644 --- a/Testing/workflow/Invoke-PSSA.Tests.ps1 +++ b/Testing/workflow/Invoke-PSSA.Tests.ps1 @@ -1,36 +1,27 @@ # The purpose of this test is to verify that PSSA is working. -# Suppress PSSA warnings here at the root of the test file. -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '')] -param() - -BeforeDiscovery { - # Source the function - . $PSScriptRoot/../../utils/workflow/Invoke-PSSA.ps1 - # Invoke PSSA - $RepoRootPath = Join-Path -Path $PSScriptRoot -ChildPath '..\..' -Resolve - $global:Output = Invoke-PSSA -DebuggingMode $false -RepoPath $RepoRootPath 6>&1 -} - -Describe "PSSA Invoke" { +Describe "PSSA Install Check" { It "PSSA should be installed" { - # # Source the function - # . $PSScriptRoot/../../utils/workflow/Invoke-PSSA.ps1 - # # Invoke PSSA - # $RepoRootPath = Join-Path -Path $PSScriptRoot -ChildPath '..\..' -Resolve - # Invoke-PSSA -DebuggingMode $false -RepoPath $RepoRootPath + # Source the function + . $PSScriptRoot/../../utils/workflow/Invoke-PSSA.ps1 + # Invoke PSSA + $RepoRootPath = Join-Path -Path $PSScriptRoot -ChildPath '..\..' -Resolve + Invoke-PSSA -DebuggingMode $false -RepoPath $RepoRootPath $Module = Get-Module -ListAvailable -Name 'PSScriptAnalyzer' $Module | Should -Not -BeNullOrEmpty } +} + +Describe "PSSA Output Check" { It "PSSA should write output" { - # # Source the function - # . $PSScriptRoot/../../utils/workflow/Invoke-PSSA.ps1 - # # Invoke PSSA - # $RepoRootPath = Join-Path -Path $PSScriptRoot -ChildPath '..\..' -Resolve - # $Output = Invoke-PSSA -DebuggingMode $false -RepoPath $RepoRootPath 6>&1 - $global:Output | Should -Not -BeNullOrEmpty + # Source the function + . $PSScriptRoot/../../utils/workflow/Invoke-PSSA.ps1 + # Invoke PSSA + $RepoRootPath = Join-Path -Path $PSScriptRoot -ChildPath '..\..' -Resolve + $Output = Invoke-PSSA -DebuggingMode $false -RepoPath $RepoRootPath 6>&1 + $Output | Should -Not -BeNullOrEmpty # Note: This is a little bit fragile. It only work as long as one of these two - # summary statements is the final output. - $global:Output | Select-Object -Last 1 | Should -BeIn @("Problems were found in the PowerShell scripts.", "No problems were found in the PowerShell scripts.") + # summary statements is the final output written. + $Output | Select-Object -Last 1 | Should -BeIn @("Problems were found in the PowerShell scripts.", "No problems were found in the PowerShell scripts.") } } \ No newline at end of file