Skip to content

Commit 65bf069

Browse files
authored
hardcoding Pester v4 (#46)
* Update InvokeTests.ps1 * Update InvokeTests.ps1
1 parent f3d3375 commit 65bf069

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tools/InvokeTests.ps1

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ param (
88
[string]$TestsToRun
99
)
1010

11-
function InstallModule ([string]$Name,[version]$Version){
12-
if (!(Get-Module $Name -List | where Version -ge $Version)) {
13-
Write-Host "Installing $Name"
14-
Install-Module -Name $Name -Force -SkipPublisherCheck -Scope CurrentUser -Repository PSGallery
11+
function InstallModule ([string]$Name,[version]$Version,[version]$MaxVersion=$null){
12+
if ($MaxVersion) {
13+
if (!(Get-Module $Name -List | where Version -ge $Version | where Version -le $MaxVersion)) {
14+
Write-Host "Installing $Name with Max Version $MaxVersion"
15+
Install-Module -Name $Name -Force -SkipPublisherCheck -Scope CurrentUser -Repository PSGallery -MaximumVersion $MaxVersion
16+
}
17+
Import-Module $Name -MaximumVersion $MaxVersion
18+
} else {
19+
if (!(Get-Module $Name -List | where Version -ge $Version)) {
20+
Write-Host "Installing $Name"
21+
Install-Module -Name $Name -Force -SkipPublisherCheck -Scope CurrentUser -Repository PSGallery
22+
}
1523
Import-Module $Name
1624
}
1725
if ($env:TF_BUILD) {Get-Module $Name -List}
@@ -32,7 +40,7 @@ if ($env:TF_BUILD) {
3240
# Install Pester and Platy, if needed
3341
#
3442

35-
InstallModule Pester '4.0.0'
43+
InstallModule Pester '4.0.0' '4.99'
3644
InstallModule PlatyPS '0.14.0'
3745
InstallModule PSScriptAnalyzer '1.17.0'
3846

@@ -53,4 +61,4 @@ switch ($TestsToRun) {
5361

5462
Write-Host "Run Pester tests"
5563
$Result = Invoke-Pester -Path "$tests/module", "$tests/functions" -Tag $Tags -PassThru -OutputFile PesterTestResults.xml
56-
if ($Result.failedCount -ne 0) {Write-Error "Pester returned errors"}
64+
if ($Result.failedCount -ne 0) {Write-Error "Pester returned errors"}

0 commit comments

Comments
 (0)