Skip to content

Commit f85d62e

Browse files
Refactor module test scripts to improve helper path resolution and add new helper functions for module import and version specification
1 parent d7085ea commit f85d62e

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

scripts/tests/Module/PSModule/helpers/Convert-VersionSpec.ps1 renamed to scripts/helpers/Convert-VersionSpec.ps1

File renamed without changes.

scripts/tests/Module/PSModule/helpers/Import-PSModule.ps1 renamed to scripts/helpers/Import-PSModule.ps1

File renamed without changes.

scripts/tests/Module/PSModule/helpers/Resolve-PSModuleDependency.ps1 renamed to scripts/helpers/Resolve-PSModuleDependency.ps1

File renamed without changes.

scripts/main.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
# If test type is module, the code we ought to test is in the WorkingDirectory/outputs/module/Name folder,
1+
$helperPath = "$PSScriptRoot/../../../helpers"
2+
Get-ChildItem -Path $helperPath -Filter '*.ps1' -Recurse | ForEach-Object {
3+
. $_.FullName
4+
}
5+
6+
# If test type is module, the code we ought to test is in the WorkingDirectory/outputs/module/Name folder,
27
# otherwise it's in the WorkingDirectory/src folder.
8+
39
$moduleName = if ([string]::IsNullOrEmpty($env:PSMODULE_TEST_PSMODULE_INPUT_Name)) {
410
$env:GITHUB_REPOSITORY_NAME
511
} else {
@@ -19,6 +25,9 @@ switch ($settings) {
1925
Priority = 100
2026
}
2127
Register-PSResourceRepository @localRepo
28+
$manifestFilePath = Join-Path -Path $codePath "$moduleName.psd1"
29+
Write-Verbose " - Manifest file path: [$manifestFilePath]" -Verbose
30+
Resolve-PSModuleDependency -ManifestFilePath $manifestFilePath
2231
Publish-PSResource -Path $codePath -Repository Local
2332
Install-PSResource -Name $moduleName -Repository Local
2433
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Param(
1010

1111
BeforeAll {
1212
LogGroup "Load module from path [$Path]" {
13-
$helperPath = (Join-Path -Path $PSScriptRoot -ChildPath 'helpers')
13+
$helperPath = "$PSScriptRoot/../../../helpers"
1414
Get-ChildItem -Path $helperPath -Filter '*.ps1' -Recurse | ForEach-Object {
1515
. $_.FullName
1616
}

0 commit comments

Comments
 (0)