From dfbfba6e251c7722f6d3b68e3624dbc7becbc64d Mon Sep 17 00:00:00 2001 From: Jeffrey Stuhr <110697945+fadwen@users.noreply.github.com> Date: Sat, 21 Nov 2026 17:59:37 -0800 Subject: [PATCH] test(logs): build the event table before the test that reads it The test "resolves a message two patterns fit to the earlier one in the table" read $script:IslAgentLogEvents from module scope before it called Get-IslAgentLogEvent, which builds the table on its first call. The test file imports the module with -Force, so whenever the shuffled order ran this test first in the file the table was $null and the test failed with "You cannot call a method on a null-valued expression". It did so in a full run under shuffle seed 1788100338. The test now makes one call first, as the neighbouring test of the compiled table already does. Closes #78 --- CHANGELOG.md | 5 +++++ Tests/Unit/Private/Get-IslAgentLogEvent.Tests.ps1 | 2 ++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44907af..8004a91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,11 @@ entries are carried over from the manifest's release notes. The PowerShell Gallery has no such limit on the list it shows, which carries two tags for every exported command, so the check could only ever refuse a release the Gallery would accept. +### Fixed + +- A test of `Get-IslAgentLogEvent` read the event table before anything had built it, so it failed + whenever the shuffled order of the CI run put it first in its file. It builds the table first. + ## [0.34.0] - 2026-10-15 A correction to the evidence behind one finding, found while writing up the validation lab. Round 9 diff --git a/Tests/Unit/Private/Get-IslAgentLogEvent.Tests.ps1 b/Tests/Unit/Private/Get-IslAgentLogEvent.Tests.ps1 index 71b4084..94ee366 100644 --- a/Tests/Unit/Private/Get-IslAgentLogEvent.Tests.ps1 +++ b/Tests/Unit/Private/Get-IslAgentLogEvent.Tests.ps1 @@ -286,6 +286,8 @@ Describe 'Get-IslAgentLogEvent' -Tag 'Unit', 'Private' { '{"ApplicationId":"ec9586f0-3333-4cfb-a8fb-d780079278f6","ResultantAppState":3,' + '"ReportingImpact":{"DesiredState":3,"Classification":1,"ConflictReason":2,"ImpactingApps":' + '[{"AppId":"b107041b-4444-4cfb-a8fb-d780079278f6","RelationshipType":0}]},"ReportingImpact2":{}}' + # The table is compiled on the first call, so make one: this test may run first + $null = InModuleScope IntuneScriptLab { Get-IslAgentLogEvent -Message 'first check in on start' } $table = InModuleScope IntuneScriptLab { $script:IslAgentLogEvents } $fitting = @($table | Where-Object { $_.Regex.IsMatch($text) } | ForEach-Object { $_.Event }) $fitting | Should-BeCollection @('AppRelationshipReport', 'AppReport')