You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
snapshot GitHub-related environment variables before the Windows token e2e test clears them
restore those variables after the test so later Windows e2e cases keep CI GitHub authentication
Root cause
The Windows Pester suite runs in a single PowerShell process. github_token.Tests.ps1 removed GITHUB_TOKEN and MISE_GITHUB_TOKEN to test credential-command behavior, but only cleaned up the credential-command variables afterward. Later tests inherited the missing token state and fell back to unauthenticated GitHub API calls.
Validation
git diff --cached --check
Not run: Windows Pester suite locally because pwsh is not installed in this environment.
Note
Low Risk
Test-only change to Pester setup/teardown; no production code or runtime behavior.
Overview
Fixes Windows Pester isolation for the GitHub token e2e test by snapshotting a fixed list of GitHub-related process env vars in BeforeEach, clearing them for the test, and restoring the saved values in AfterEach.
Previously the suite only removed token vars and restored two credential/shell vars afterward, so later cases in the same PowerShell run could lose CI GITHUB_TOKEN / MISE_GITHUB_TOKEN and hit unauthenticated GitHub API calls.
Reviewed by Cursor Bugbot for commit f5edcfe. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Tests
Improved test environment variable handling and restoration logic for GitHub token testing, enhancing test reliability and maintainability.
Pester test setup for GitHub token handling is refactored to centralize environment variable management. A new BeforeAll block defines a list of GitHub-related variable names; BeforeEach captures their current values and unsets them; AfterEach restores the originals. Test logic is unchanged.
Changes
GitHub Token Test Fixture Refactoring
Layer / File(s)
Summary
Centralized environment variable capture and restoration e2e-win/github_token.Tests.ps1
BeforeAll defines a centralized array of GitHub environment variable names. BeforeEach snapshots their current values into a hash and unsets them. AfterEach restores original values from the snapshot.
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~8 minutes
A test that whispers, now speaks loud and clear, Env vars grouped up—no hardcode here! Snapshot and restore, the dance so fine, One list to rule them all, by design! 🐰✨
This PR fixes test-isolation pollution in the Windows Pester suite where github_token.Tests.ps1 was clearing GITHUB_TOKEN and related env vars without restoring them, causing later tests to lose GitHub authentication.
The old BeforeEach deleted all six token-related env vars; the old AfterEach only removed two of them (MISE_GITHUB_CREDENTIAL_COMMAND and MISE_WINDOWS_DEFAULT_INLINE_SHELL_ARGS), leaving GITHUB_TOKEN, GITHUB_API_TOKEN, MISE_GITHUB_TOKEN, and MISE_GITHUB_ENTERPRISE_TOKEN missing for any subsequent test.
The new approach uses [Environment]::GetEnvironmentVariable in BeforeEach to snapshot all six values before clearing them, and [Environment]::SetEnvironmentVariable in AfterEach to restore each one (passing $null correctly removes variables that were absent before the test).
Confidence Score: 5/5
Safe to merge — the change only affects test scaffolding and correctly restores environment state after each test case.
The change is a targeted test-isolation fix in a single Pester file. The snapshot/restore logic is correct: saving $null for unset variables and passing $null back to SetEnvironmentVariable properly removes them, while set values are faithfully restored. No production code is touched.
No files require special attention.
Important Files Changed
Filename
Overview
e2e-win/github_token.Tests.ps1
Adds snapshot/restore of all six GitHub-related env vars in BeforeEach/AfterEach, fixing test pollution that left GITHUB_TOKEN unset for subsequent Windows e2e tests.
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
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.
Summary
Root cause
The Windows Pester suite runs in a single PowerShell process.
github_token.Tests.ps1removedGITHUB_TOKENandMISE_GITHUB_TOKENto test credential-command behavior, but only cleaned up the credential-command variables afterward. Later tests inherited the missing token state and fell back to unauthenticated GitHub API calls.Validation
git diff --cached --checkpwshis not installed in this environment.Note
Low Risk
Test-only change to Pester setup/teardown; no production code or runtime behavior.
Overview
Fixes Windows Pester isolation for the GitHub token e2e test by snapshotting a fixed list of GitHub-related process env vars in
BeforeEach, clearing them for the test, and restoring the saved values inAfterEach.Previously the suite only removed token vars and restored two credential/shell vars afterward, so later cases in the same PowerShell run could lose CI
GITHUB_TOKEN/MISE_GITHUB_TOKENand hit unauthenticated GitHub API calls.Reviewed by Cursor Bugbot for commit f5edcfe. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Note: No end-user-facing changes in this release.