Closed
Fix Pester 5 TagFilter, Health tests invoke actual functions, update Pattern C docs#607
Conversation
- Add Utilities.Tests.ps1: Format-* and Confirm-IpAddress* unit tests - Add Health.Tests.ps1: provisioning/configuration state, MAC duplicate detection - Expand NetworkController.Tests.ps1: Get-SdnGateway, Get-SdnLoadBalancerMux, Get-SdnResource - Replace all mock data with consistent DVLAB-prefixed randomized names - Update RunTests.ps1: add -Tag and -TestFile parameters, handle wrapped JSON - Add CONTRIBUTING_TESTS.md: instructions for adding new Pester tests - Update README.md: document new runner options, link to CONTRIBUTING_TESTS.md Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d38da7cf-014a-4a03-950b-4ba39152b58d
- Add 'Pester Tests' workflow (pester-tests.yml): runs offline tests on every push to main and every PR targeting main - Add 'Run Offline Pester Tests' step to build-pipeline.yml so tests gate the publish step Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d38da7cf-014a-4a03-950b-4ba39152b58d
Online tests required a live SDN environment on a self-hosted runner and are no longer maintained. All validation is now covered by the offline mock-based Pester tests. Removed: - .github/workflows/server2019-sdntest.yml - .github/workflows/server2019-sdntest-pr.yml - tests/online/ (RunTests.ps1, config sample, wave1/, waveAll/) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d38da7cf-014a-4a03-950b-4ba39152b58d
- Create .github/instructions/pester-tests.instructions.md with full skill guide (patterns, mock data, naming, CI, running tests) - Add Pester Testing section to .github/copilot-instructions.md - Remove online test references from CONTRIBUTING_TESTS.md (online tests were deleted in prior commit) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d38da7cf-014a-4a03-950b-4ba39152b58d
- .github/prompts/create-pester-test.prompt.md: reusable slash command to generate offline Pester tests for any function - .github/instructions/pester-review.instructions.md: code review rule that flags PRs adding/modifying functions without corresponding tests Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d38da7cf-014a-4a03-950b-4ba39152b58d
Single prompt that creates a new function following project conventions AND generates its corresponding offline Pester tests in one invocation. Instructions files remain separate for passive context loading. - Remove: .github/prompts/create-pester-test.prompt.md - Add: .github/prompts/add-sdn-function.prompt.md Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d38da7cf-014a-4a03-950b-4ba39152b58d
- Use InModuleScope SdnDiagnostics for private utility functions - Use InModuleScope SdnDiag.NetworkController with Mock Invoke-RestMethodWithRetry for NC REST functions (nested module session state requires this pattern) - Fix MAC duplicate test @() wrapper for Group-Object single-result - Add outboundNatRules back-reference to LB mock data - Update instruction docs with correct mock patterns Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d38da7cf-014a-4a03-950b-4ba39152b58d
- RunTests.ps1: add -PassThru and failure propagation - Workflows: route through RunTests.ps1 for consistent exit codes - Health.Tests.ps1: rewrite as data structure validation tests (direct invocation blocked by [TraceLevel] cross-module limitation) - CONTRIBUTING_TESTS.md: rewrite with accurate patterns and limitation docs - README.md: remove online test references, offline-only layout - add-sdn-function.prompt.md: fix module location table - pester-review.instructions.md: add manifest export check Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d38da7cf-014a-4a03-950b-4ba39152b58d
- pester-tests.instructions.md: add applyTo frontmatter for scope targeting - pester-tests.instructions.md: document singleton fixture exception (no wrapper) - add-sdn-function.prompt.md: note singleton format for config endpoints - copilot-instructions.md: fix Pattern B to correctly reference Invoke-RestMethodWithRetry - Utilities.Tests.ps1: add /0 CIDR edge case (documents known bit-shift limitation) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d38da7cf-014a-4a03-950b-4ba39152b58d
Resolve modify/delete conflicts: online test workflows were intentionally removed in this branch. Accept our deletion over main's modifications. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d38da7cf-014a-4a03-950b-4ba39152b58d
- Fix Confirm-IpAddressInCidrRange: special-case prefix length 0 to avoid 32-bit shift wrap (modulo 32 made /0 behave like /32) - Update test to assert correct /0 behavior (Should -BeTrue) - Fix 'one assertion per It' rule to 'one behavior per It' in both pester-tests.instructions.md and CONTRIBUTING_TESTS.md - Fix BeforeAll mock guidance: mocks must live inside InModuleScope blocks, not in BeforeAll outside them Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d38da7cf-014a-4a03-950b-4ba39152b58d
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
… actual functions
Copilot
AI
changed the title
[WIP] Fix code based on review comments
Fix Pester 5 TagFilter, Health tests invoke actual functions, update Pattern C docs
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes three open review comments from PR #606's review thread.
Description
Summary of changes:
tests/offline/RunTests.ps1: Changed$pesterParams.Tag→$pesterParams.TagFilter. Pester 5 usesTagFilter; the old key silently added an unsupported parameter toInvoke-Pester, causing tag-filtered runs to fail before executing any tests.tests/offline/Health.Tests.ps1: Replaced fixture-only validation tests with tests that actually invokeTest-SdnResourceProvisioningStateandTest-SdnResourceConfigurationStateinsideInModuleScope SdnDiag.HealthwithMock Get-SdnResource. The old tests would remain green if the health functions were removed or broken.Get-SdnResourceis mockable in Health's scope becauseSdnDiag.Health.psm1explicitly importsSdnDiag.NetworkController.psm1. Tests now cover FAIL/PASS/WARNING branches and the guard clause that skips config-state checks whenprovisioningStateis notSucceeded.tests/CONTRIBUTING_TESTS.md: Updated Pattern C from "validate fixture data structures" to the correctInModuleScope SdnDiag.Health+Mock Get-SdnResourceinvocation pattern with explanation.Change type
Checklist: