File tree 2 files changed +17
-3
lines changed
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,8 @@ function Import-Pester {
34
34
35
35
36
36
if ((Get-Module - Name PowerShellGet - ListAvailable) -and
37
- (Get-Command Install-Module ).Parameters.ContainsKey(' SkipPublisherCheck' )) {
37
+ (Get-Command Install-Module ).Parameters.ContainsKey(' SkipPublisherCheck' ) -and
38
+ (Get-PSRepository )) {
38
39
39
40
try {
40
41
$null = Get-PackageProvider - Name NuGet - ErrorAction Stop
Original file line number Diff line number Diff line change @@ -152,7 +152,20 @@ Describe "Testing Helper Functions" {
152
152
Import-Pester - Version " latest"
153
153
154
154
Assert-MockCalled - CommandName Install-Module - Times 0 - Scope It
155
- Assert-MockCalled - CommandName Import-Module - Times 1 - ParameterFilter {$Name -like ' *\4.6.0\Pester.psd1' }
155
+ Assert-MockCalled - CommandName Import-Module - Times 1 - ParameterFilter {$Name -like ' *\4.10.1\Pester.psd1' }
156
+ }
157
+
158
+ It " Should fall back to build in version of Pester when no repositories are available" {
159
+ Mock - CommandName Get-PSRepository - MockWith {}
160
+ Mock - CommandName Get-Command - MockWith { [PsCustomObject ]@ {Parameters = @ {SkipPublisherCheck = ' SomeValue' }}} - ParameterFilter {$Name -eq ' Install-Module' }
161
+
162
+ Import-Pester - Version " latest"
163
+
164
+ Assert-MockCalled - CommandName Install-Module - Times 0 - Scope It
165
+ Assert-MockCalled - CommandName Write-Host - Times 1 - Scope It - ParameterFilter {
166
+ $Object -eq " ##vso[task.logissue type=warning]Falling back to version of Pester shipped with extension. To use a newer version please update the version of PowerShellGet available on this machine."
167
+ }
168
+ Assert-MockCalled - CommandName Import-Module - Times 1 - ParameterFilter {$Name -like ' *\4.10.1\Pester.psd1' }
156
169
}
157
170
158
171
<# It "Loads Pester version that ships with task when not on PS5+ or PowerShellGet is unavailable" {
@@ -164,7 +177,7 @@ Describe "Testing Helper Functions" {
164
177
Mock -CommandName Get-Module -MockWith { }
165
178
166
179
&$sut -ScriptFolder TestDrive:\ -ResultsFile TestDrive:\output.xml
167
- Assert-MockCalled Import-Module -ParameterFilter { $Name -eq "$pwd\4.6.0 \Pester.psd1" }
180
+ Assert-MockCalled Import-Module -ParameterFilter { $Name -eq "$pwd\4.10.1 \Pester.psd1" }
168
181
Assert-MockCalled Invoke-Pester
169
182
}#>
170
183
}
You can’t perform that action at this time.
0 commit comments