Skip to content

Commit

Permalink
try catch the PS version
Browse files Browse the repository at this point in the history
  • Loading branch information
james-garriss committed Jul 26, 2024
1 parent 1f2dc10 commit 5971a55
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Testing/workflow/Publish-ScubaGear.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,20 @@ Describe "Edit-ManifestFile" {
Write-Warning "The manifest file path is $ManifestFilePath"
# 99.1 is an intentionally invalid number
Get-Content "$ModuleFolderPath\ScubaGear.psd1" | ForEach-Object { $_ -replace '5.1', '99.1' } | Set-Content $ManifestFilePath
$AnErrorWasCaught = $false
# This function should throw an error.
Edit-ManifestFile `
-ModuleDestinationPath $global:ModuleDestinationPath `
-OverrideModuleVersion '4.5.6' `
-PrereleaseTag 'GoodbyeWorld'
$Error.Count | Should -BeGreaterThan 0
try {
Edit-ManifestFile `
-ModuleDestinationPath $global:ModuleDestinationPath `
-OverrideModuleVersion '4.5.6' `
-PrereleaseTag 'GoodbyeWorld'
}
catch {
$AnErrorWasCaught = $true
$Error.Count | Should -BeGreaterThan 0
}
# Double-check to make sure there was an exception
$AnErrorWasCaught | Should -Be $true
}
}

Expand Down

0 comments on commit 5971a55

Please sign in to comment.