Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit c12a27a

Browse files
Brandon OlinBrandon Olin
authored andcommitted
Merge from upstream
2 parents e5010a3 + 5a1de3f commit c12a27a

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1616

1717
### Fixed
1818

19-
- PR25 Discovery Pester 'Describe' block names when the -Name parameter is used (via @GitAMBS)
19+
- PR25 - Discover Pester 'Describe' block names when the -Name parameter is used (via @GitAMBS)
20+
- PR29 - Remove Pester 4.0+ warning by using -Show parameter instead of -Quiet. Add -UseBasicParsing parameter to Invoke-WebRequest in tests (via @larssb)
2021
- Fixed #3 where an error would be generated when using Invoke-OperationValidation with the -TestFilePath parameter
2122
against a Pester test file with a short path.
2223

OperationValidation/Public/Invoke-OperationValidation.ps1

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,12 @@ function Invoke-OperationValidation
170170

171171
BEGIN
172172
{
173-
if ( -not (Get-Module -Name Pester))
173+
$pesterMod = Get-Module -Name Pester
174+
if ( -not $pesterMod)
174175
{
175176
if ( Get-Module -Name Pester -ListAvailable)
176177
{
177-
Import-Module -Name Pester -Verbose:$false
178+
$pesterMod = Import-Module -Name Pester -Verbose:$false -PassThru
178179
}
179180
else
180181
{
@@ -259,7 +260,6 @@ function Invoke-OperationValidation
259260
}
260261

261262
# Pester 4.0.0 deprecated the 'Quiet' parameter in favor of 'Show'
262-
$pesterMod = Get-Module -Name Pester
263263
if ($pesterMod.Version -ge '4.0.0')
264264
{
265265
if ($IncludePesterOutput)
@@ -323,10 +323,32 @@ function Invoke-OperationValidation
323323

324324
if ($TestFilePath)
325325
{
326+
$pesterParams = @{
327+
PassThru = $true
328+
Verbose = $false
329+
}
330+
331+
# Pester 4.0.0 deprecated the 'Quiet' parameter in favor of 'Show'
332+
if ($pesterMod.Version -ge '4.0.0')
333+
{
334+
if ($IncludePesterOutput)
335+
{
336+
$pesterParams.Show = 'All'
337+
}
338+
else
339+
{
340+
$pesterParams.Show = 'None'
341+
}
342+
}
343+
else
344+
{
345+
$pesterParams.Quiet = !$IncludePesterOutput
346+
}
347+
326348
foreach($filePath in $TestFilePath) {
327349
write-progress -Activity "Invoking tests in $filePath"
328350
if ( $PSCmdlet.ShouldProcess($filePath)) {
329-
$testResult = Invoke-Pester $filePath -passthru -quiet:$quiet
351+
$testResult = Invoke-Pester $filePath @pesterParams
330352
Add-Member -InputObject $testResult -MemberType NoteProperty -Name Path -Value $filePath
331353
Convert-TestResult -Result $testResult
332354
}

TestArtifacts/VersionedModule/1.0.0/Diagnostics/Simple/PSGallery.Simple.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ param(
55

66
Describe 'Simple Validation of PSGallery' -Tag 'AAABBBCCC' {
77
It 'The PowerShell Gallery should be responsive' {
8-
$response = Invoke-WebRequest -Uri $WebsiteUrl
8+
$response = Invoke-WebRequest -Uri $WebsiteUrl -UseBasicParsing
99
$response.StatusCode | Should Be $StatusCode
1010
}
1111

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
Describe 'Simple Validation of PSGallery' -Tag 'AAABBBCCC' {
22
It 'The PowerShell Gallery should be responsive' {
3-
$response = Invoke-WebRequest -Uri 'https://www.powershellgallery.com'
3+
$response = Invoke-WebRequest -Uri 'https://www.powershellgallery.com' -UseBasicParsing
44
$response.StatusCode | Should be 200
55
}
66
}
77

88
Describe 'Simple Validation of Microsoft' -Tag 'AAABBBCCC', 'XXXYYYZZZ' {
99
It 'Microsoft should be responsive' {
10-
$response = Invoke-WebRequest -Uri 'https://www.microsoft.com'
10+
$response = Invoke-WebRequest -Uri 'https://www.microsoft.com' -UseBasicParsing
1111
$response.StatusCode | Should be 200
1212
}
1313
}
1414

1515

1616
Describe 'Simple Validation of Github' -Tag 'JJJKKKLLL' {
1717
It 'GitHub should be responsive' {
18-
$response = Invoke-WebRequest -Uri 'https://www.github.com'
18+
$response = Invoke-WebRequest -Uri 'https://www.github.com' -UseBasicParsing
1919
$response.StatusCode | Should be 200
2020
}
2121
}

0 commit comments

Comments
 (0)