Skip to content

Commit 1cb1b0c

Browse files
MSBrettmsbrettgithub-actions[bot]Copilot
authored
Migrate PowerShell tests to Pester 6 (#2204)
Co-authored-by: msbrett <msbrett@users.no-reply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent def67b0 commit 1cb1b0c

5 files changed

Lines changed: 18 additions & 17 deletions

File tree

‎.github/workflows/dev.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Install and cache PowerShell modules
1313
uses: potatoqualitee/psmodulecache@v6.2.1
1414
with:
15-
modules-to-cache: InvokeBuild, PSScriptAnalyzer, Pester, Az.Accounts, Az.Resources
15+
modules-to-cache: InvokeBuild, PSScriptAnalyzer, Pester:6.0.0, Az.Accounts, Az.Resources
1616
shell: pwsh
1717
- uses: actions/checkout@v3
1818
- name: Run Tests

‎docs-mslearn/toolkit/changelog.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: FinOps toolkit changelog
33
description: Review the latest features and enhancements in the FinOps toolkit, including updates to FinOps hubs, Power BI reports, and more.
44
author: MSBrett
55
ms.author: brettwil
6-
ms.date: 07/07/2026
6+
ms.date: 07/29/2026
77
ms.topic: reference
88
ms.service: finops
99
ms.subservice: finops-toolkit
@@ -78,6 +78,8 @@ _Released June 2026_
7878

7979
### [PowerShell module](powershell/powershell-commands.md) v15
8080

81+
- **Changed**
82+
- Updated PowerShell test compatibility with Pester 6 ([#2204](https://github.com/microsoft/finops-toolkit/pull/2204)).
8183
- **Fixed**
8284
- Fixed [Get-FinOpsCostExport](powershell/cost/get-finopscostexport.md) `-RunHistory` to return the complete run history ([#2063](https://github.com/microsoft/finops-toolkit/issues/2063)).
8385
- Bumped the `Az.Accounts` required-module minimum to 2.17.0 so dependency resolution can't land on a version missing the `Get-AzAccessToken -AsSecureString` parameter that `Invoke-Rest` relies on ([#2185](https://github.com/microsoft/finops-toolkit/issues/2185)).

‎src/powershell/Tests/Initialize-Tests.ps1‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
Remove-Module FinOpsToolkit -ErrorAction SilentlyContinue
55
Import-Module -FullyQualifiedName "$PSScriptRoot/../FinOpsToolkit.psm1"
6-
Import-Module Pester -Global -ErrorAction Stop
76

87
BeforeAll {
98
# Bring the Monitor functions in to simplify debugging

‎src/powershell/Tests/Unit/DocsLinks.Tests.ps1‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Describe 'Documentation links' {
257257

258258
Context 'docs-mslearn: Internal relative links' {
259259

260-
It 'Should resolve to an existing file: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -ForEach $mslearnInternalLinks {
260+
It 'Should resolve to an existing file: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -AllowNullOrEmptyForEach -ForEach $mslearnInternalLinks {
261261
$sourceDir = Split-Path $SourceFile -Parent
262262

263263
if ([string]::IsNullOrEmpty($PathPart))
@@ -270,7 +270,7 @@ Describe 'Documentation links' {
270270
$resolvedPath | Should -Not -BeNullOrEmpty -Because "link target '$PathPart' in ${SourceRel}:${LineNumber} should resolve to an existing file"
271271
}
272272

273-
It 'Should have a valid anchor: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -ForEach ($mslearnInternalLinks | Where-Object { $_.AnchorPart }) {
273+
It 'Should have a valid anchor: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -AllowNullOrEmptyForEach -ForEach ($mslearnInternalLinks | Where-Object { $_.AnchorPart }) {
274274
$sourceDir = Split-Path $SourceFile -Parent
275275
$resolvedPath = Join-Path $sourceDir $PathPart
276276

@@ -288,7 +288,7 @@ Describe 'Documentation links' {
288288
Context 'docs-mslearn: No learn.microsoft.com URLs' {
289289
$learnMicrosoftLinks = @($mslearnUrls | Where-Object { $_.Url -match 'learn\.microsoft\.com' })
290290
if ($learnMicrosoftLinks.Count -gt 0) {
291-
It 'Should not contain https://learn.microsoft.com links: <SourceRel>:<LineNumber>' -ForEach $learnMicrosoftLinks {
291+
It 'Should not contain https://learn.microsoft.com links: <SourceRel>:<LineNumber>' -AllowNullOrEmptyForEach -ForEach $learnMicrosoftLinks {
292292
$Url | Should -Not -Match 'learn\.microsoft\.com' -Because "links in docs-mslearn should use root-relative paths (e.g., /azure/...) instead of full URLs since docs are deployed to learn.microsoft.com (${SourceRel}:${LineNumber})"
293293
}
294294
}
@@ -302,7 +302,7 @@ Describe 'Documentation links' {
302302
Context 'docs-mslearn: No language locale in MS Learn links' {
303303
$localizedMsLearnLinks = @($mslearnUrls | Where-Object { $_.Url -match 'learn\.microsoft\.com/[a-z]{2}-[a-z]{2}/' })
304304
if ($localizedMsLearnLinks.Count -gt 0) {
305-
It 'Should not contain language locale in URL: <SourceRel>:<LineNumber> <Url>' -ForEach $localizedMsLearnLinks {
305+
It 'Should not contain language locale in URL: <SourceRel>:<LineNumber> <Url>' -AllowNullOrEmptyForEach -ForEach $localizedMsLearnLinks {
306306
$Url | Should -Not -Match 'learn\.microsoft\.com/[a-z]{2}-[a-z]{2}/' -Because "MS Learn links should not include language locale segments like /en-us/ (${SourceRel}:${LineNumber})"
307307
}
308308
}
@@ -315,7 +315,7 @@ Describe 'Documentation links' {
315315

316316
Context 'docs-mslearn: No known broken external URLs' {
317317
if ($knownBrokenExternalUrlMatches.Count -gt 0) {
318-
It 'Should not contain known broken external URL: <SourceRel>:<LineNumber> <Url>' -ForEach $knownBrokenExternalUrlMatches {
318+
It 'Should not contain known broken external URL: <SourceRel>:<LineNumber> <Url>' -AllowNullOrEmptyForEach -ForEach $knownBrokenExternalUrlMatches {
319319
$Url | Should -Not -Match $Pattern -Because "known broken external URLs should not appear in docs-mslearn content (${SourceRel}:${LineNumber})"
320320
}
321321
}
@@ -328,7 +328,7 @@ Describe 'Documentation links' {
328328

329329
Context 'docs-mslearn: No incomplete placeholder external URLs' {
330330
if ($incompleteExternalUrlMatches.Count -gt 0) {
331-
It 'Should not contain incomplete placeholder URL: <SourceRel>:<LineNumber> <Url>' -ForEach $incompleteExternalUrlMatches {
331+
It 'Should not contain incomplete placeholder URL: <SourceRel>:<LineNumber> <Url>' -AllowNullOrEmptyForEach -ForEach $incompleteExternalUrlMatches {
332332
$Url | Should -Not -Match $Pattern -Because "incomplete placeholder URLs should not appear in docs-mslearn content (${SourceRel}:${LineNumber})"
333333
}
334334
}
@@ -345,7 +345,7 @@ Describe 'Documentation links' {
345345

346346
Context 'docs: Internal relative links' {
347347

348-
It 'Should resolve to an existing file: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -ForEach $jekyllInternalLinks {
348+
It 'Should resolve to an existing file: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -AllowNullOrEmptyForEach -ForEach $jekyllInternalLinks {
349349
$sourceDir = Split-Path $SourceFile -Parent
350350

351351
if ([string]::IsNullOrEmpty($PathPart))
@@ -358,7 +358,7 @@ Describe 'Documentation links' {
358358
$resolvedPath | Should -Not -BeNullOrEmpty -Because "link target '$PathPart' in ${SourceRel}:${LineNumber} should resolve to an existing file"
359359
}
360360

361-
It 'Should have a valid anchor: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -ForEach ($jekyllInternalLinks | Where-Object { $_.AnchorPart }) {
361+
It 'Should have a valid anchor: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -AllowNullOrEmptyForEach -ForEach ($jekyllInternalLinks | Where-Object { $_.AnchorPart }) {
362362
$sourceDir = Split-Path $SourceFile -Parent
363363
$resolvedPath = Join-Path $sourceDir $PathPart
364364

@@ -379,7 +379,7 @@ Describe 'Documentation links' {
379379

380380
Context 'docs-wiki: Wiki page links' {
381381

382-
It 'Should reference an existing wiki page: <SourceRel>:<LineNumber> [[<DisplayText>]]' -ForEach $wikiPageLinks {
382+
It 'Should reference an existing wiki page: <SourceRel>:<LineNumber> [[<DisplayText>]]' -AllowNullOrEmptyForEach -ForEach $wikiPageLinks {
383383
$pageFileName = ($PageName -replace '\s', '-') + '.md'
384384
# Case-insensitive match against actual wiki files
385385
$found = $wikiPageFileNames | Where-Object { $_ -ieq $pageFileName }
@@ -389,7 +389,7 @@ Describe 'Documentation links' {
389389

390390
Context 'docs-wiki: Repo-relative links' {
391391

392-
It 'Should resolve to an existing repo path: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -ForEach $wikiRepoLinks {
392+
It 'Should resolve to an existing repo path: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -AllowNullOrEmptyForEach -ForEach $wikiRepoLinks {
393393
$fullPath = Join-Path $repoRoot $RepoPath
394394
$exists = (Test-Path $fullPath) -or (Test-Path "$fullPath.md")
395395
$exists | Should -BeTrue -Because "repo-relative link '$RepoPath' in ${SourceRel}:${LineNumber} should point to an existing file or directory"
@@ -398,7 +398,7 @@ Describe 'Documentation links' {
398398

399399
Context 'docs-wiki: Internal relative links' {
400400

401-
It 'Should resolve to an existing file: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -ForEach $wikiInternalLinks {
401+
It 'Should resolve to an existing file: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -AllowNullOrEmptyForEach -ForEach $wikiInternalLinks {
402402
$sourceDir = Split-Path $SourceFile -Parent
403403

404404
if ([string]::IsNullOrEmpty($PathPart))
@@ -418,7 +418,7 @@ Describe 'Documentation links' {
418418

419419
Context 'Root files: Internal relative links' {
420420

421-
It 'Should resolve to an existing file: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -ForEach $rootInternalLinks {
421+
It 'Should resolve to an existing file: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -AllowNullOrEmptyForEach -ForEach $rootInternalLinks {
422422
$sourceDir = Split-Path $SourceFile -Parent
423423

424424
if ([string]::IsNullOrEmpty($PathPart))
@@ -431,7 +431,7 @@ Describe 'Documentation links' {
431431
$resolvedPath | Should -Not -BeNullOrEmpty -Because "link target '$PathPart' in ${SourceRel}:${LineNumber} should resolve to an existing file"
432432
}
433433

434-
It 'Should have a valid anchor: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -ForEach ($rootInternalLinks | Where-Object { $_.AnchorPart }) {
434+
It 'Should have a valid anchor: <SourceRel>:<LineNumber> [<LinkText>](<LinkTarget>)' -AllowNullOrEmptyForEach -ForEach ($rootInternalLinks | Where-Object { $_.AnchorPart }) {
435435
$sourceDir = Split-Path $SourceFile -Parent
436436
$resolvedPath = Join-Path $sourceDir $PathPart
437437

‎src/powershell/Tests/Unit/New-Directory.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
& "$PSScriptRoot/../Initialize-Tests.ps1"
55

66
InModuleScope 'FinOpsToolkit' {
7-
BeforeAll {
7+
BeforeDiscovery {
88
function New-MockReleaseObject
99
{
1010
param

0 commit comments

Comments
 (0)