From c324981a17a802cd749cc976d5ef9c9a1d4ac1c4 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 2 Jun 2024 13:42:00 +0200 Subject: [PATCH] Simplify setup.tests, avoid error log --- tests/setup.Tests.ps1 | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/setup.Tests.ps1 b/tests/setup.Tests.ps1 index 601a1e0e8..e58a4729d 100644 --- a/tests/setup.Tests.ps1 +++ b/tests/setup.Tests.ps1 @@ -1,13 +1,4 @@ -# Ensure the specific version 5.3.1 of Pester is installed and imported -$RequiredVersion = [version]"5.3.1" -$InstalledModule = Get-Module -ListAvailable -Name Pester -if (-not ($InstalledModule) -or ($InstalledModule.Version -lt $RequiredVersion)) { - Install-Module -Name Pester -RequiredVersion $RequiredVersion -Force -Scope CurrentUser -SkipPublisherCheck -} -Import-Module -Name Pester -MinimumVersion 5.3.1 - -# Describe block to contain all tests and setup Describe "Setup and Tests" { BeforeAll { # Setup variables @@ -28,7 +19,9 @@ Describe "Setup and Tests" { Context "Write-Log Tests" -Tag "Unit" { It "should write INFO level log" { - Remove-Item $Global:LogFilePath -ErrorAction SilentlyContinue + if (Test-Path $Global:LogFilePath){ + Remove-Item $Global:LogFilePath -ErrorAction SilentlyContinue + } Write-Log -Message "Test Info Message" -Level "INFO" $Global:LogFilePath | Should -Exist @@ -38,7 +31,9 @@ Describe "Setup and Tests" { } It "should write ERROR level log" { - Remove-Item $Global:LogFilePath -ErrorAction SilentlyContinue + if (Test-Path $Global:LogFilePath){ + Remove-Item $Global:LogFilePath -ErrorAction SilentlyContinue + } Write-Log -Message "Test Error Message" -Level "ERROR" $Global:LogFilePath | Should -Exist