Skip to content

Commit 3d59679

Browse files
committed
Let Pester handle after all
1 parent ddb4e10 commit 3d59679

File tree

1 file changed

+17
-51
lines changed

1 file changed

+17
-51
lines changed

Tests/Public/Build-Module.Tests.ps1

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,10 @@ Describe "Build-Module" {
303303
[IO.FileInfo]"$TestDrive/MyModule/Public/Get-MyInfo.ps1"
304304
}
305305

306-
try {
307-
Build-Module -SemVer $SemVer
308-
} catch {
309-
Pop-Location -StackName BuildModuleTest
310-
throw
311-
}
306+
Build-Module -SemVer $SemVer
307+
}
308+
AfterAll {
309+
Pop-Location -StackName BuildModuleTest
312310
}
313311

314312
It "Should build to an output folder with the simple version." {
@@ -336,12 +334,7 @@ Describe "Build-Module" {
336334
# If there's no release notes, but it was left uncommented
337335
Mock Get-Metadata { "" }
338336

339-
try {
340-
Build-Module -SemVer $SemVer
341-
} catch {
342-
Pop-Location -StackName BuildModuleTest
343-
throw
344-
}
337+
Build-Module -SemVer $SemVer
345338

346339
Assert-MockCalled Update-Metadata -ParameterFilter {
347340
$PropertyName -eq "PrivateData.PSData.ReleaseNotes" -and $Value -eq "MyModule v$SemVer"
@@ -354,12 +347,7 @@ Describe "Build-Module" {
354347
Multi-line Release Notes
355348
With a prefix carriage return" }
356349

357-
try {
358-
Build-Module -SemVer $SemVer
359-
} catch {
360-
Pop-Location -StackName BuildModuleTest
361-
throw
362-
}
350+
Build-Module -SemVer $SemVer
363351

364352
Assert-MockCalled Update-Metadata -ParameterFilter {
365353
$PropertyName -eq "PrivateData.PSData.ReleaseNotes" -and $Value -eq "
@@ -368,9 +356,6 @@ Describe "Build-Module" {
368356
With a prefix carriage return"
369357
}
370358
}
371-
AfterAll {
372-
Pop-Location -StackName BuildModuleTest
373-
}
374359
}
375360

376361
Context "Setting the version and pre-release" {
@@ -414,12 +399,11 @@ Describe "Build-Module" {
414399
[IO.FileInfo]"$TestDrive/MyModule/Public/Get-MyInfo.ps1"
415400
}
416401

417-
try {
418-
Build-Module @SemVer
419-
} catch {
420-
Pop-Location -StackName BuildModuleTest
421-
throw
422-
}
402+
Build-Module @SemVer
403+
}
404+
405+
AfterAll {
406+
Pop-Location -StackName BuildModuleTest
423407
}
424408

425409
It "Should build to an output folder with the simple version." {
@@ -448,12 +432,7 @@ Describe "Build-Module" {
448432
# If there's no release notes, but it was left uncommented
449433
Mock Get-Metadata { "" }
450434

451-
try {
452-
Build-Module @SemVer
453-
} catch {
454-
Pop-Location -StackName BuildModuleTest
455-
throw
456-
}
435+
Build-Module @SemVer
457436

458437
Assert-MockCalled Update-Metadata -ParameterFilter {
459438
$PropertyName -eq "PrivateData.PSData.ReleaseNotes" -and
@@ -467,12 +446,7 @@ Describe "Build-Module" {
467446
Multi-line Release Notes
468447
With a prefix carriage return" }
469448

470-
try {
471-
Build-Module @SemVer
472-
} catch {
473-
Pop-Location -StackName BuildModuleTest
474-
throw
475-
}
449+
Build-Module @SemVer
476450

477451
Assert-MockCalled Update-Metadata -ParameterFilter {
478452
$PropertyName -eq "PrivateData.PSData.ReleaseNotes" -and $Value -eq "
@@ -481,9 +455,6 @@ Describe "Build-Module" {
481455
With a prefix carriage return"
482456
}
483457
}
484-
AfterAll {
485-
Pop-Location -StackName BuildModuleTest
486-
}
487458
}
488459

489460
Context "Setting the version with no pre-release" {
@@ -518,12 +489,10 @@ Describe "Build-Module" {
518489
[IO.FileInfo]"$TestDrive/MyModule/Public/Get-MyInfo.ps1"
519490
}
520491

521-
try {
522-
Build-Module @SemVer
523-
} catch {
524-
Pop-Location -StackName BuildModuleTest
525-
throw
526-
}
492+
Build-Module @SemVer
493+
}
494+
AfterAll {
495+
Pop-Location -StackName BuildModuleTest
527496
}
528497

529498
It "Should build to an output folder with the simple version." {
@@ -541,9 +510,6 @@ Describe "Build-Module" {
541510
$PropertyName -eq "PrivateData.PSData.Prerelease"
542511
} -Scope Context
543512
}
544-
AfterAll {
545-
Pop-Location -StackName BuildModuleTest
546-
}
547513
}
548514

549515
Context "Bug #70 Cannot build 1.2.3-pre-release" {

0 commit comments

Comments
 (0)