Skip to content

Storage Metrics phase 6: migrate to Pester 5 - #42

Merged
tjsullivan1 merged 1 commit into
tjsullivan1-storage-metrics-phase-5from
tjsullivan1-storage-metrics-phase-6
Oct 21, 2026
Merged

tjsullivan1 merged 1 commit into
tjsullivan1-storage-metrics-phase-5from
tjsullivan1-storage-metrics-phase-6

Conversation

@tjsullivan1

Copy link
Copy Markdown
Owner

Summary

Phase 6 only, stacked on #41 (tjsullivan1-storage-metrics-phase-5, commit 958caf2).

  • Migrate all six test files to Pester 5.7.1: runtime imports and offline Az stubs in BeforeAll, module-scoped mocks, parameterized assertions, and Should -Invoke call checks.
  • Route every production UTC read through private Get-UtcNow and mock a fixed UTC instant. Cover exact capacity ages and evidence timestamps, HTTP-date retry delays, and elapsed report deadlines.
  • Pin Pester 5.7.1 in CI and update offline verification instructions. Use -CI for failing test/discovery exit status and NUnit output.

The public commands, exports, null-versus-zero handling, caps/reconciliation, account buffering, saved Az contexts/explicit -DefaultProfile, decimal handling, and signed-URL redaction are unchanged.

Verification

  • Before migration: Pester 3.4.0, 190 passed.
  • After migration: Pester 5.7.1 with -CI, 192 passed; zero failures, skipped tests, or discovery errors.
  • All 190 original test names retained; two additional clock behaviors covered.
  • ScriptAnalyzer: zero errors or warnings using the existing repository settings.
  • git diff --check: clean. Direct system-clock access is confined to Private/Get-UtcNow.ps1.
  • Tests ran without Az modules or credentials; external service and delay boundaries remained mocked.

Standards

Reviewed independently against .github/copilot-instructions.md, existing module patterns, and the code-smell baseline. The helper uses an approved verb, typed output, comment-based help, and the existing private-module layout. No new public API or runtime dependency. 0 remaining findings.

Spec

Reviewed independently against the exact Phase 6 requirements. All six fixtures, CI, docs, and all nine production clock reads are migrated. Existing behavior names and coverage are preserved or increased. Changes to Phase 5 production code are limited to the required clock seam. 0 remaining findings.

Review totals: Standards 0; Spec 0. No outstanding issue on either axis.

Move fixture setup to BeforeAll, retain module-scoped offline mocks, and route UTC reads through an internal clock. Preserve all 190 original tests and add retry-date and polling-deadline coverage. Pin Pester 5.7.1 in CI and verification docs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bab1d34b-d8d8-4bd1-8a3a-5e44f606ee9d

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The migration and clock substitutions preserve existing behavior, with no unresolved blocking findings; tests were not rerun during this review.

No open issues 🎉

What changed in this PR

Migrates StorageMetrics to Pester 5 after Phase 5’s module packaging, adding deterministic clock-based testing without changing the public API.

Changes:

  • Migrates all six fixtures to Pester 5 assertions and runtime setup.
  • Routes production UTC reads through private Get-UtcNow and strengthens timing assertions.
  • Pins Pester 5.7.1 in CI and updates offline verification instructions.
File Description
PowerShell/​StorageMetrics/​tests/​StorageMetrics.Module.Tests.ps1 Migrates interface checks and verifies clock-helper privacy.
PowerShell/​StorageMetrics/​tests/​Get-AzStorageWorkloadBaseline.Tests.ps1 Migrates baseline tests with fixed dates.
PowerShell/​StorageMetrics/​tests/​Get-AzStorageTransactionMetric.Tests.ps1 Migrates transaction tests and adds HTTP-date retry coverage.
PowerShell/​StorageMetrics/​tests/​Get-AzStorageRedundancyCost.Tests.ps1 Migrates pricing tests and checks evidence timestamps.
PowerShell/​StorageMetrics/​tests/​Get-AzStorageCostComparison.Tests.ps1 Migrates billing tests and adds elapsed-deadline coverage.
PowerShell/​StorageMetrics/​tests/​Get-AzStorageCapacity.Tests.ps1 Migrates capacity tests and asserts exact sample ages.
PowerShell/​StorageMetrics/​StorageTransactionMetrics.md Updates offline verification guidance.
PowerShell/​StorageMetrics/​Public/​Get-AzStorageTransactionMetric.ps1 Uses the private clock for validation and timestamps.
PowerShell/​StorageMetrics/​Public/​Get-AzStorageRedundancyCost.ps1 Uses the private clock for pricing timestamps.
PowerShell/​StorageMetrics/​Private/​Invoke-StorageArmGet.ps1 Uses the private clock for retry delays.
PowerShell/​StorageMetrics/​Private/​Get-UtcNow.ps1 Adds the mockable UTC clock helper.
PowerShell/​StorageMetrics/​Private/​Get-StorageCapacityRecord.ps1 Uses the private clock for sample ages.
PowerShell/​StorageMetrics/​Private/​Get-LiveCostRows.ps1 Uses the private clock for polling deadlines.
.github/​workflows/​storagemetrics-tests.yml Pins Pester and enables CI failure reporting.

Review effort: Balanced

@tjsullivan1
tjsullivan1 merged commit 45e0dfc into tjsullivan1-storage-metrics-phase-5 Oct 21, 2026
3 checks passed
@tjsullivan1
tjsullivan1 deleted the tjsullivan1-storage-metrics-phase-6 branch October 21, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants