Skip to content

test(logs): build the event table before the test that reads it - #80

Merged
fadwen merged 2 commits into
mainfrom
test/agent-log-event-order
Nov 23, 2026
Merged

fadwen merged 2 commits into
mainfrom
test/agent-log-event-order

Conversation

@fadwen

@fadwen fadwen commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Summary

One test of Get-IslAgentLogEvent passed only when another test had run before it in the same file, so it failed whenever the shuffled order of the CI run put it first. The test now builds the event table before it reads it. Closes #78.

Changes

  • Tests/Unit/Private/Get-IslAgentLogEvent.Tests.ps1: "resolves a message two patterns fit to the earlier one in the table" calls Get-IslAgentLogEvent once before it reads $script:IslAgentLogEvents from module scope. The function builds that table on its first call, and the neighbouring test of the compiled table already makes the same call for the same reason.
  • CHANGELOG.md: an entry under Fixed.

Verification

Run on Windows 11 26H2 with PowerShell 7.6.10 and Windows PowerShell 5.1.26100.

  • The test run on its own, with Filter.FullName = '*resolves a message two patterns fit*': failed before the change with You cannot call a method on a null-valued expression, and passes after it, on both PowerShell versions.
  • The whole file, shuffled: 62 passed, 0 failed, on both PowerShell versions.
  • PSScriptAnalyzer 1.25.0 on the file, Error and Warning: 0 findings.
  • The full suite was not run again for this change. It was run on the branch this one is based on, and this change touches one test.

Notes

  • This pull request is stacked on fix(release): bring the build scripts in line with the 2.0 standards #79 and merges after it. Its base is fix/release-script-standards.
  • The module is not affected: Get-IntuneAgentLog calls Get-IslAgentLogEvent -Message '' before it reads the table.
  • No other test reads state that is built on first use: the other reads of module scope in the suites are of $script:RuleOrder, which the root module sets when it is imported.

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

@fadwen fadwen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Verdict: approve. Verified in a Linux sandbox with pwsh 7.6.0 and Pester 6.2.0.

  • Closes #78: with Filter.FullName = '*resolves a message two patterns fit*', the test fails on #79 with "You cannot call a method on a null-valued expression" and passes on this branch.
  • Whole file, shuffled: 62/62 passed.

Base automatically changed from fix/release-script-standards to main November 23, 2026 10:09
@fadwen
fadwen merged commit a39e9c0 into main Nov 23, 2026
4 checks passed
@fadwen
fadwen deleted the test/agent-log-event-order branch November 23, 2026 10:09
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.

A Get-IslAgentLogEvent test fails when the shuffle runs it first in its file

1 participant