Skip to content

Commit 45990fa

Browse files
Refactor PSModule.Tests.ps1 to streamline module import and manifest path retrieval
1 parent 3587cbc commit 45990fa

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

scripts/tests/Module/PSModule/PSModule.Tests.ps1

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,20 @@ Param(
88
[string] $Path
99
)
1010

11+
BeforeAll {
12+
$moduleName = Split-Path -Path (Split-Path -Path $Path -Parent) -Leaf
13+
$moduleManifestPath = Join-Path -Path $Path -ChildPath "$moduleName.psd1"
14+
Write-Verbose "Module Manifest Path: [$moduleManifestPath]"
15+
}
16+
1117
Describe 'PSModule - Module tests' {
1218
Context 'Module' {
1319
It 'The module should be importable' {
14-
{
15-
$moduleName = Split-Path -Path $Path -Leaf
16-
Import-Module -Name $moduleName
17-
} | Should -Not -Throw
20+
{ Import-Module -Name $moduleName } | Should -Not -Throw
1821
}
1922
}
2023

2124
Context 'Module Manifest' {
22-
BeforeAll {
23-
$moduleName = Split-Path -Path $Path -Leaf
24-
$moduleManifestPath = Join-Path -Path $Path -ChildPath "$moduleName.psd1"
25-
Write-Verbose "Module Manifest Path: [$moduleManifestPath]"
26-
}
2725
It 'Module Manifest exists' {
2826
$result = Test-Path -Path $moduleManifestPath
2927
$result | Should -Be $true

0 commit comments

Comments
 (0)