From 84d99ad85c230372a1ffde46ce568869ea904e16 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 22:57:51 +0000 Subject: [PATCH 01/10] Initial plan From 581213bfe0807304544f2f7bc68ca8d63b46d927 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 23:04:11 +0000 Subject: [PATCH 02/10] Add BeforeAll.ps1 and AfterAll.ps1 for global test setup/teardown Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/AfterAll.ps1 | 283 ++++++++++++++++++++++++++++++++++++++++++++ tests/BeforeAll.ps1 | 281 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 564 insertions(+) create mode 100644 tests/AfterAll.ps1 create mode 100644 tests/BeforeAll.ps1 diff --git a/tests/AfterAll.ps1 b/tests/AfterAll.ps1 new file mode 100644 index 000000000..ae02559db --- /dev/null +++ b/tests/AfterAll.ps1 @@ -0,0 +1,283 @@ +<# +.SYNOPSIS + Global teardown script that runs once after all parallel tests complete. + +.DESCRIPTION + This script is executed by the Process-PSModule workflow after all tests have run. + It performs final cleanup tasks to ensure no test artifacts are left behind: + - Removes any remaining test resources that weren't cleaned up by individual tests + - Generates a final cleanup report + - Helps prevent resource accumulation from failed tests + + Individual test files handle their own cleanup in AfterAll blocks, but this + provides a safety net for any resources that might have been missed. + +.NOTES + This script is called automatically by Process-PSModule workflow. + It uses the same cleanup logic as BeforeAll.ps1 to ensure consistent cleanup. +#> + +[CmdletBinding()] +param() + +$ErrorActionPreference = 'Continue' +$WarningPreference = 'Continue' + +LogGroup 'AfterAll - Global Test Teardown' { + Write-Host "Starting global test teardown at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" + Write-Host "Runner OS: $env:RUNNER_OS" + Write-Host "GitHub Actions: $env:GITHUB_ACTIONS" + + # Track statistics + $stats = @{ + RepositoriesRemoved = 0 + TeamsRemoved = 0 + EnvironmentsRemoved = 0 + SecretsRemoved = 0 + VariablesRemoved = 0 + AppInstallationsRemoved = 0 + Errors = 0 + } + + # Test name prefixes used across test files + $testPrefixes = @( + 'RepositoriesTests' + 'TeamsTests' + 'EnvironmentsTests' + 'SecretsTests' + 'VariablesTests' + 'AppsTests' + 'ArtifactsTests' + 'ReleasesTests' + 'PermissionsTests' + 'MsxOrgTests' + 'GitHubTests' + ) + + # Get all authentication scenarios + $authCases = . "$PSScriptRoot/Data/AuthCases.ps1" + + Write-Host "`nPerforming final cleanup of test resources..." + Write-Host "Test prefixes to clean: $($testPrefixes -join ', ')" + + # Process each auth case to clean up remaining resources + foreach ($authCase in $authCases) { + $owner = $authCase.Owner + $ownerType = $authCase.OwnerType + $tokenType = $authCase.TokenType + $authType = $authCase.AuthType + + LogGroup "Final Cleanup - $owner ($ownerType) using $tokenType" { + try { + # Connect to GitHub + Write-Host "Connecting to GitHub as $owner..." + $context = Connect-GitHubAccount @($authCase.ConnectParams) -PassThru -Silent -ErrorAction Stop + + # For APP auth, also connect to the app installation + if ($authType -eq 'APP') { + Write-Host "Connecting to GitHub App installation..." + $context = Connect-GitHubApp @($authCase.ConnectAppParams) -PassThru -Default -Silent -ErrorAction Stop + } + + # Clean up repositories + Write-Host "Checking for remaining repositories..." + try { + $repos = switch ($ownerType) { + 'user' { + Get-GitHubRepository -ErrorAction SilentlyContinue | + Where-Object { + $repoName = $_.Name + $testPrefixes | Where-Object { $repoName -like "$_-*" } + } + } + 'organization' { + Get-GitHubRepository -Organization $owner -ErrorAction SilentlyContinue | + Where-Object { + $repoName = $_.Name + $testPrefixes | Where-Object { $repoName -like "$_-*" } + } + } + default { @() } + } + + if ($repos) { + Write-Host "Found $($repos.Count) repositories to remove" + foreach ($repo in $repos) { + try { + Write-Host " Removing repository: $($repo.FullName)" + $repo | Remove-GitHubRepository -Confirm:$false -ErrorAction Stop + $stats.RepositoriesRemoved++ + } catch { + Write-Warning " Failed to remove repository $($repo.FullName): $_" + $stats.Errors++ + } + } + } else { + Write-Host "No repositories found (good - tests cleaned up after themselves)" + } + } catch { + Write-Warning "Error cleaning repositories: $_" + $stats.Errors++ + } + + # Clean up teams (organization only) + if ($ownerType -eq 'organization') { + Write-Host "Checking for remaining teams..." + try { + $teams = Get-GitHubTeam -Organization $owner -ErrorAction SilentlyContinue | + Where-Object { + $teamName = $_.Name + $testPrefixes | Where-Object { $teamName -like "$_*" } + } + + if ($teams) { + Write-Host "Found $($teams.Count) teams to remove" + foreach ($team in $teams) { + try { + Write-Host " Removing team: $($team.Name)" + $team | Remove-GitHubTeam -Confirm:$false -ErrorAction Stop + $stats.TeamsRemoved++ + } catch { + Write-Warning " Failed to remove team $($team.Name): $_" + $stats.Errors++ + } + } + } else { + Write-Host "No teams found (good - tests cleaned up after themselves)" + } + } catch { + Write-Warning "Error cleaning teams: $_" + $stats.Errors++ + } + + # Clean up organization secrets + Write-Host "Checking for remaining organization secrets..." + try { + $secrets = Get-GitHubSecret -Owner $owner -ErrorAction SilentlyContinue | + Where-Object { + $secretName = $_.Name + $testPrefixes | Where-Object { $secretName -like "$_*" } + } + + if ($secrets) { + Write-Host "Found $($secrets.Count) secrets to remove" + foreach ($secret in $secrets) { + try { + Write-Host " Removing secret: $($secret.Name)" + $secret | Remove-GitHubSecret -ErrorAction Stop + $stats.SecretsRemoved++ + } catch { + Write-Warning " Failed to remove secret $($secret.Name): $_" + $stats.Errors++ + } + } + } else { + Write-Host "No secrets found (good - tests cleaned up after themselves)" + } + } catch { + Write-Warning "Error cleaning secrets: $_" + $stats.Errors++ + } + + # Clean up organization variables + Write-Host "Checking for remaining organization variables..." + try { + $variables = Get-GitHubVariable -Owner $owner -ErrorAction SilentlyContinue | + Where-Object { + $variableName = $_.Name + $testPrefixes | Where-Object { $variableName -like "$_*" } + } + + if ($variables) { + Write-Host "Found $($variables.Count) variables to remove" + foreach ($variable in $variables) { + try { + Write-Host " Removing variable: $($variable.Name)" + $variable | Remove-GitHubVariable -ErrorAction Stop + $stats.VariablesRemoved++ + } catch { + Write-Warning " Failed to remove variable $($variable.Name): $_" + $stats.Errors++ + } + } + } else { + Write-Host "No variables found (good - tests cleaned up after themselves)" + } + } catch { + Write-Warning "Error cleaning variables: $_" + $stats.Errors++ + } + } + + # Clean up app installations (APP auth only) + if ($authType -eq 'APP') { + Write-Host "Checking for remaining app installations..." + try { + # Reconnect as the app (not installation) to manage installations + Disconnect-GitHubAccount -Silent + $context = Connect-GitHubAccount @($authCase.ConnectParams) -PassThru -Silent -ErrorAction Stop + + $installations = Get-GitHubAppInstallation -ErrorAction SilentlyContinue | + Where-Object { + $targetName = $_.Target.Name + $testPrefixes | Where-Object { $targetName -like "$_*" } + } + + if ($installations) { + Write-Host "Found $($installations.Count) app installations to remove" + foreach ($installation in $installations) { + try { + Write-Host " Uninstalling from: $($installation.Target.Name)" + $installation | Uninstall-GitHubApp -Confirm:$false -ErrorAction Stop + $stats.AppInstallationsRemoved++ + } catch { + Write-Warning " Failed to uninstall from $($installation.Target.Name): $_" + $stats.Errors++ + } + } + } else { + Write-Host "No app installations found (good - tests cleaned up after themselves)" + } + } catch { + Write-Warning "Error cleaning app installations: $_" + $stats.Errors++ + } + } + + # Disconnect after cleanup + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent + + } catch { + Write-Warning "Failed to process $owner ($ownerType): $_" + $stats.Errors++ + # Ensure we disconnect even on error + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent + } + } + } + + # Report cleanup statistics + LogGroup 'Final Cleanup Summary' { + Write-Host "`nGlobal test teardown completed at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" + Write-Host "Final Cleanup Statistics:" + Write-Host " Repositories removed: $($stats.RepositoriesRemoved)" + Write-Host " Teams removed: $($stats.TeamsRemoved)" + Write-Host " Environments removed: $($stats.EnvironmentsRemoved)" + Write-Host " Secrets removed: $($stats.SecretsRemoved)" + Write-Host " Variables removed: $($stats.VariablesRemoved)" + Write-Host " App installations removed: $($stats.AppInstallationsRemoved)" + Write-Host " Errors encountered: $($stats.Errors)" + Write-Host "" + + if ($stats.RepositoriesRemoved -eq 0 -and $stats.TeamsRemoved -eq 0 -and + $stats.SecretsRemoved -eq 0 -and $stats.VariablesRemoved -eq 0) { + Write-Host "✓ Excellent! All tests cleaned up their resources properly." + } elseif ($stats.Errors -eq 0) { + Write-Host "✓ Final cleanup completed successfully. Some resources were left behind by tests." + } else { + Write-Warning "Some cleanup operations failed. Manual cleanup may be required." + } + } +} + +Write-Host "AfterAll.ps1 completed" diff --git a/tests/BeforeAll.ps1 b/tests/BeforeAll.ps1 new file mode 100644 index 000000000..54f85f232 --- /dev/null +++ b/tests/BeforeAll.ps1 @@ -0,0 +1,281 @@ +<# +.SYNOPSIS + Global setup script that runs once before all parallel tests. + +.DESCRIPTION + This script is executed by the Process-PSModule workflow before any tests run. + It performs infrastructure setup tasks that benefit all test runs: + - Cleans up stale resources from previous failed test runs + - Reduces rate limiting by removing orphaned test artifacts upfront + + Individual test files still handle their own: + - Authentication (Connect-GitHubAccount, Connect-GitHubApp) + - Resource creation (repositories, teams, environments) + - Resource cleanup (in their AfterAll blocks) + +.NOTES + This script is called automatically by Process-PSModule workflow. + Tests continue to create their own isolated resources to support parallel execution. +#> + +[CmdletBinding()] +param() + +$ErrorActionPreference = 'Continue' +$WarningPreference = 'Continue' + +LogGroup 'BeforeAll - Global Test Setup' { + Write-Host "Starting global test setup at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" + Write-Host "Runner OS: $env:RUNNER_OS" + Write-Host "GitHub Actions: $env:GITHUB_ACTIONS" + + # Track statistics + $stats = @{ + RepositoriesRemoved = 0 + TeamsRemoved = 0 + EnvironmentsRemoved = 0 + SecretsRemoved = 0 + VariablesRemoved = 0 + AppInstallationsRemoved = 0 + Errors = 0 + } + + # Test name prefixes used across test files + $testPrefixes = @( + 'RepositoriesTests' + 'TeamsTests' + 'EnvironmentsTests' + 'SecretsTests' + 'VariablesTests' + 'AppsTests' + 'ArtifactsTests' + 'ReleasesTests' + 'PermissionsTests' + 'MsxOrgTests' + 'GitHubTests' + ) + + # Get all authentication scenarios + $authCases = . "$PSScriptRoot/Data/AuthCases.ps1" + + Write-Host "`nCleaning up stale resources from previous test runs..." + Write-Host "Test prefixes to clean: $($testPrefixes -join ', ')" + + # Process each auth case to clean up stale resources + foreach ($authCase in $authCases) { + $owner = $authCase.Owner + $ownerType = $authCase.OwnerType + $tokenType = $authCase.TokenType + $authType = $authCase.AuthType + + LogGroup "Cleanup - $owner ($ownerType) using $tokenType" { + try { + # Connect to GitHub + Write-Host "Connecting to GitHub as $owner..." + $context = Connect-GitHubAccount @($authCase.ConnectParams) -PassThru -Silent -ErrorAction Stop + + # For APP auth, also connect to the app installation + if ($authType -eq 'APP') { + Write-Host "Connecting to GitHub App installation..." + $context = Connect-GitHubApp @($authCase.ConnectAppParams) -PassThru -Default -Silent -ErrorAction Stop + } + + # Clean up repositories + Write-Host "Checking for stale repositories..." + try { + $repos = switch ($ownerType) { + 'user' { + Get-GitHubRepository -ErrorAction SilentlyContinue | + Where-Object { + $repoName = $_.Name + $testPrefixes | Where-Object { $repoName -like "$_-*" } + } + } + 'organization' { + Get-GitHubRepository -Organization $owner -ErrorAction SilentlyContinue | + Where-Object { + $repoName = $_.Name + $testPrefixes | Where-Object { $repoName -like "$_-*" } + } + } + default { @() } + } + + if ($repos) { + Write-Host "Found $($repos.Count) stale repositories to remove" + foreach ($repo in $repos) { + try { + Write-Host " Removing repository: $($repo.FullName)" + $repo | Remove-GitHubRepository -Confirm:$false -ErrorAction Stop + $stats.RepositoriesRemoved++ + } catch { + Write-Warning " Failed to remove repository $($repo.FullName): $_" + $stats.Errors++ + } + } + } else { + Write-Host "No stale repositories found" + } + } catch { + Write-Warning "Error cleaning repositories: $_" + $stats.Errors++ + } + + # Clean up teams (organization only) + if ($ownerType -eq 'organization') { + Write-Host "Checking for stale teams..." + try { + $teams = Get-GitHubTeam -Organization $owner -ErrorAction SilentlyContinue | + Where-Object { + $teamName = $_.Name + $testPrefixes | Where-Object { $teamName -like "$_*" } + } + + if ($teams) { + Write-Host "Found $($teams.Count) stale teams to remove" + foreach ($team in $teams) { + try { + Write-Host " Removing team: $($team.Name)" + $team | Remove-GitHubTeam -Confirm:$false -ErrorAction Stop + $stats.TeamsRemoved++ + } catch { + Write-Warning " Failed to remove team $($team.Name): $_" + $stats.Errors++ + } + } + } else { + Write-Host "No stale teams found" + } + } catch { + Write-Warning "Error cleaning teams: $_" + $stats.Errors++ + } + + # Clean up organization secrets + Write-Host "Checking for stale organization secrets..." + try { + $secrets = Get-GitHubSecret -Owner $owner -ErrorAction SilentlyContinue | + Where-Object { + $secretName = $_.Name + $testPrefixes | Where-Object { $secretName -like "$_*" } + } + + if ($secrets) { + Write-Host "Found $($secrets.Count) stale secrets to remove" + foreach ($secret in $secrets) { + try { + Write-Host " Removing secret: $($secret.Name)" + $secret | Remove-GitHubSecret -ErrorAction Stop + $stats.SecretsRemoved++ + } catch { + Write-Warning " Failed to remove secret $($secret.Name): $_" + $stats.Errors++ + } + } + } else { + Write-Host "No stale secrets found" + } + } catch { + Write-Warning "Error cleaning secrets: $_" + $stats.Errors++ + } + + # Clean up organization variables + Write-Host "Checking for stale organization variables..." + try { + $variables = Get-GitHubVariable -Owner $owner -ErrorAction SilentlyContinue | + Where-Object { + $variableName = $_.Name + $testPrefixes | Where-Object { $variableName -like "$_*" } + } + + if ($variables) { + Write-Host "Found $($variables.Count) stale variables to remove" + foreach ($variable in $variables) { + try { + Write-Host " Removing variable: $($variable.Name)" + $variable | Remove-GitHubVariable -ErrorAction Stop + $stats.VariablesRemoved++ + } catch { + Write-Warning " Failed to remove variable $($variable.Name): $_" + $stats.Errors++ + } + } + } else { + Write-Host "No stale variables found" + } + } catch { + Write-Warning "Error cleaning variables: $_" + $stats.Errors++ + } + } + + # Clean up app installations (APP auth only) + if ($authType -eq 'APP') { + Write-Host "Checking for stale app installations..." + try { + # Reconnect as the app (not installation) to manage installations + Disconnect-GitHubAccount -Silent + $context = Connect-GitHubAccount @($authCase.ConnectParams) -PassThru -Silent -ErrorAction Stop + + $installations = Get-GitHubAppInstallation -ErrorAction SilentlyContinue | + Where-Object { + $targetName = $_.Target.Name + $testPrefixes | Where-Object { $targetName -like "$_*" } + } + + if ($installations) { + Write-Host "Found $($installations.Count) stale app installations to remove" + foreach ($installation in $installations) { + try { + Write-Host " Uninstalling from: $($installation.Target.Name)" + $installation | Uninstall-GitHubApp -Confirm:$false -ErrorAction Stop + $stats.AppInstallationsRemoved++ + } catch { + Write-Warning " Failed to uninstall from $($installation.Target.Name): $_" + $stats.Errors++ + } + } + } else { + Write-Host "No stale app installations found" + } + } catch { + Write-Warning "Error cleaning app installations: $_" + $stats.Errors++ + } + } + + # Disconnect after cleanup + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent + + } catch { + Write-Warning "Failed to process $owner ($ownerType): $_" + $stats.Errors++ + # Ensure we disconnect even on error + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent + } + } + } + + # Report cleanup statistics + LogGroup 'Cleanup Summary' { + Write-Host "`nGlobal test setup completed at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" + Write-Host "Cleanup Statistics:" + Write-Host " Repositories removed: $($stats.RepositoriesRemoved)" + Write-Host " Teams removed: $($stats.TeamsRemoved)" + Write-Host " Environments removed: $($stats.EnvironmentsRemoved)" + Write-Host " Secrets removed: $($stats.SecretsRemoved)" + Write-Host " Variables removed: $($stats.VariablesRemoved)" + Write-Host " App installations removed: $($stats.AppInstallationsRemoved)" + Write-Host " Errors encountered: $($stats.Errors)" + Write-Host "" + + if ($stats.Errors -gt 0) { + Write-Warning "Some cleanup operations failed. Tests may encounter issues with existing resources." + } else { + Write-Host "All cleanup operations completed successfully." + } + } +} + +Write-Host "BeforeAll.ps1 completed" From e68238d3ec86a262b2c9143fab98a63956051889 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 23:06:30 +0000 Subject: [PATCH 03/10] Add documentation for test setup/teardown scripts Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/README-SETUP-TEARDOWN.md | 159 +++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 tests/README-SETUP-TEARDOWN.md diff --git a/tests/README-SETUP-TEARDOWN.md b/tests/README-SETUP-TEARDOWN.md new file mode 100644 index 000000000..227cd06dd --- /dev/null +++ b/tests/README-SETUP-TEARDOWN.md @@ -0,0 +1,159 @@ +# Test Setup/Teardown Scripts + +This document describes the global test setup and teardown scripts used in the GitHub module test suite. + +## Overview + +The GitHub module uses Process-PSModule's BeforeAll/AfterAll support to optimize test execution and reduce rate limiting issues. + +### Key Concepts + +1. **BeforeAll.ps1** - Runs once before all parallel test jobs + - Cleans up stale resources from previous failed test runs + - Reduces rate limiting by removing orphaned artifacts upfront + - Does NOT replace individual test BeforeAll blocks + +2. **AfterAll.ps1** - Runs once after all parallel test jobs complete + - Performs final cleanup of any remaining test resources + - Provides a safety net for resources missed by individual tests + - Generates a cleanup report + +3. **Individual Test Files** - Keep their existing BeforeAll/AfterAll blocks + - Handle authentication (Connect-GitHubAccount, Connect-GitHubApp) + - Create and clean up their own isolated resources + - Support parallel execution across different auth scenarios + +## How It Works + +### Before Tests Run + +``` +Process-PSModule Workflow + ↓ +BeforeAll.ps1 (runs once) + ↓ +Parallel Test Matrix + ├─ Test File 1 → BeforeAll → Tests → AfterAll + ├─ Test File 2 → BeforeAll → Tests → AfterAll + └─ Test File 3 → BeforeAll → Tests → AfterAll + ↓ +AfterAll.ps1 (runs once) +``` + +### What Gets Cleaned Up + +Both BeforeAll.ps1 and AfterAll.ps1 clean up test resources across all authentication scenarios: + +- **Repositories**: Any repository with test name prefixes (e.g., `RepositoriesTests-*`) +- **Teams**: Teams created during tests (organization contexts only) +- **Secrets**: Organization secrets created during tests +- **Variables**: Organization variables created during tests +- **App Installations**: GitHub App installations on test organizations (APP auth only) + +### Resource Naming Convention + +Tests use a consistent naming pattern that allows the cleanup scripts to identify test resources: + +```powershell +$testName = 'RepositoriesTests' # Test file identifier +$os = $env:RUNNER_OS # Linux, Windows, macOS +$tokenType = 'USER_FG_PAT' # Auth type identifier +$guid = [guid]::NewGuid() # Unique run identifier + +$resourceName = "$testName-$os-$tokenType-$guid" +``` + +Examples: +- `RepositoriesTests-Linux-USER_FG_PAT-a1b2c3d4` +- `TeamsTests-Windows-APP_ORG-e5f6g7h8` + +The cleanup scripts look for resources matching the test name prefixes (e.g., `RepositoriesTests-*`). + +## Benefits + +1. **Speed**: Pre-cleanup ensures tests don't encounter conflicts with stale resources +2. **Rate Limiting**: Significantly fewer API calls by removing orphaned resources upfront +3. **Reliability**: Consistent test environment across all test runs +4. **Cost**: Fewer parallel operations hitting API rate limits +5. **Maintainability**: Centralized cleanup logic in two files + +## Test Prefixes + +The following test prefixes are recognized by the cleanup scripts: + +- `RepositoriesTests` +- `TeamsTests` +- `EnvironmentsTests` +- `SecretsTests` +- `VariablesTests` +- `AppsTests` +- `ArtifactsTests` +- `ReleasesTests` +- `PermissionsTests` +- `MsxOrgTests` +- `GitHubTests` + +## Authentication Scenarios + +The cleanup scripts process all authentication scenarios defined in `tests/Data/AuthCases.ps1`: + +1. **Fine-grained PAT** - User account (`psmodule-user`) +2. **Fine-grained PAT** - Organization account (`psmodule-test-org2`) +3. **Classic PAT** - User account (`psmodule-user`) +4. **GitHub Actions Token** - Repository context (`PSModule/GitHub`) +5. **GitHub App** - Organization installation (`psmodule-test-org`) +6. **GitHub App** - Enterprise installation (`psmodule-test-org3`) +7. **GitHub App** - Enterprise context (`msx`) + +## Cleanup Statistics + +Both scripts generate statistics showing: +- Number of repositories removed +- Number of teams removed +- Number of secrets removed +- Number of variables removed +- Number of app installations removed +- Number of errors encountered + +## Example Output + +``` +BeforeAll - Global Test Setup + Cleanup - psmodule-user (user) using USER_FG_PAT + Connecting to GitHub as psmodule-user... + Checking for stale repositories... + Found 3 stale repositories to remove + Removing repository: psmodule-user/RepositoriesTests-Linux-USER_FG_PAT-old1 + Removing repository: psmodule-user/TeamsTests-Linux-USER_FG_PAT-old2 + Removing repository: psmodule-user/SecretsTests-Linux-USER_FG_PAT-old3 + No stale teams found + + Cleanup Summary + Repositories removed: 12 + Teams removed: 5 + Secrets removed: 3 + Variables removed: 2 + App installations removed: 0 + Errors encountered: 0 + + All cleanup operations completed successfully. +``` + +## Troubleshooting + +### Tests Fail Due to Missing Resources + +The cleanup scripts only remove resources that match test name prefixes. If your tests are failing due to missing resources, ensure your test is creating its own resources in the BeforeAll block. + +### Cleanup Script Errors + +If the cleanup scripts encounter errors, they will continue processing other resources. Check the error messages in the workflow logs to identify the issue. Common causes: +- Insufficient permissions for the authentication token +- Rate limiting (should be rare with pre-cleanup) +- Network connectivity issues + +### Resources Not Being Cleaned + +Ensure your test resources follow the naming convention: `{TestName}-{OS}-{TokenType}-{GUID}` + +The cleanup scripts look for resources starting with the test name prefixes listed above. From 5a69d8e79f02b05bd2dc41b3131fc17e24a681d7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 23:09:43 +0000 Subject: [PATCH 04/10] Fix hashtable splatting syntax in BeforeAll.ps1 and AfterAll.ps1 Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/AfterAll.ps1 | 6 +++--- tests/BeforeAll.ps1 | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/AfterAll.ps1 b/tests/AfterAll.ps1 index ae02559db..b84239d90 100644 --- a/tests/AfterAll.ps1 +++ b/tests/AfterAll.ps1 @@ -71,12 +71,12 @@ LogGroup 'AfterAll - Global Test Teardown' { try { # Connect to GitHub Write-Host "Connecting to GitHub as $owner..." - $context = Connect-GitHubAccount @($authCase.ConnectParams) -PassThru -Silent -ErrorAction Stop + $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop # For APP auth, also connect to the app installation if ($authType -eq 'APP') { Write-Host "Connecting to GitHub App installation..." - $context = Connect-GitHubApp @($authCase.ConnectAppParams) -PassThru -Default -Silent -ErrorAction Stop + $context = Connect-GitHubApp @authCase.ConnectAppParams -PassThru -Default -Silent -ErrorAction Stop } # Clean up repositories @@ -215,7 +215,7 @@ LogGroup 'AfterAll - Global Test Teardown' { try { # Reconnect as the app (not installation) to manage installations Disconnect-GitHubAccount -Silent - $context = Connect-GitHubAccount @($authCase.ConnectParams) -PassThru -Silent -ErrorAction Stop + $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop $installations = Get-GitHubAppInstallation -ErrorAction SilentlyContinue | Where-Object { diff --git a/tests/BeforeAll.ps1 b/tests/BeforeAll.ps1 index 54f85f232..9f02002c8 100644 --- a/tests/BeforeAll.ps1 +++ b/tests/BeforeAll.ps1 @@ -72,12 +72,12 @@ LogGroup 'BeforeAll - Global Test Setup' { try { # Connect to GitHub Write-Host "Connecting to GitHub as $owner..." - $context = Connect-GitHubAccount @($authCase.ConnectParams) -PassThru -Silent -ErrorAction Stop + $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop # For APP auth, also connect to the app installation if ($authType -eq 'APP') { Write-Host "Connecting to GitHub App installation..." - $context = Connect-GitHubApp @($authCase.ConnectAppParams) -PassThru -Default -Silent -ErrorAction Stop + $context = Connect-GitHubApp @authCase.ConnectAppParams -PassThru -Default -Silent -ErrorAction Stop } # Clean up repositories @@ -216,7 +216,7 @@ LogGroup 'BeforeAll - Global Test Setup' { try { # Reconnect as the app (not installation) to manage installations Disconnect-GitHubAccount -Silent - $context = Connect-GitHubAccount @($authCase.ConnectParams) -PassThru -Silent -ErrorAction Stop + $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop $installations = Get-GitHubAppInstallation -ErrorAction SilentlyContinue | Where-Object { From 8ec4641a28c7677c625a7e1a746934c3e64e8414 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 23:11:48 +0000 Subject: [PATCH 05/10] Add context logging for better debugging visibility Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/AfterAll.ps1 | 3 +++ tests/BeforeAll.ps1 | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/AfterAll.ps1 b/tests/AfterAll.ps1 index b84239d90..a88e3f47c 100644 --- a/tests/AfterAll.ps1 +++ b/tests/AfterAll.ps1 @@ -72,11 +72,13 @@ LogGroup 'AfterAll - Global Test Teardown' { # Connect to GitHub Write-Host "Connecting to GitHub as $owner..." $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop + Write-Host "Connected as: $($context.Login)" # For APP auth, also connect to the app installation if ($authType -eq 'APP') { Write-Host "Connecting to GitHub App installation..." $context = Connect-GitHubApp @authCase.ConnectAppParams -PassThru -Default -Silent -ErrorAction Stop + Write-Host "Connected to installation: $($context.Installation.ID)" } # Clean up repositories @@ -216,6 +218,7 @@ LogGroup 'AfterAll - Global Test Teardown' { # Reconnect as the app (not installation) to manage installations Disconnect-GitHubAccount -Silent $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop + Write-Host "Reconnected as app: $($context.ClientID)" $installations = Get-GitHubAppInstallation -ErrorAction SilentlyContinue | Where-Object { diff --git a/tests/BeforeAll.ps1 b/tests/BeforeAll.ps1 index 9f02002c8..8d242e2b5 100644 --- a/tests/BeforeAll.ps1 +++ b/tests/BeforeAll.ps1 @@ -73,11 +73,13 @@ LogGroup 'BeforeAll - Global Test Setup' { # Connect to GitHub Write-Host "Connecting to GitHub as $owner..." $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop + Write-Host "Connected as: $($context.Login)" # For APP auth, also connect to the app installation if ($authType -eq 'APP') { Write-Host "Connecting to GitHub App installation..." $context = Connect-GitHubApp @authCase.ConnectAppParams -PassThru -Default -Silent -ErrorAction Stop + Write-Host "Connected to installation: $($context.Installation.ID)" } # Clean up repositories @@ -217,6 +219,7 @@ LogGroup 'BeforeAll - Global Test Setup' { # Reconnect as the app (not installation) to manage installations Disconnect-GitHubAccount -Silent $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop + Write-Host "Reconnected as app: $($context.ClientID)" $installations = Get-GitHubAppInstallation -ErrorAction SilentlyContinue | Where-Object { From 268c05c5bf9cf1d75a1404ad458e68211100d55a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 6 Jan 2026 17:10:21 +0100 Subject: [PATCH 06/10] Refactor: Move app authentication to BeforeAll blocks --- tests/Emojis.Tests.ps1 | 18 +++++------------- tests/Users.Tests.ps1 | 15 +++++---------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/tests/Emojis.Tests.ps1 b/tests/Emojis.Tests.ps1 index ff3100a2e..92d5308f4 100644 --- a/tests/Emojis.Tests.ps1 +++ b/tests/Emojis.Tests.ps1 @@ -28,26 +28,18 @@ Describe 'Emojis' { LogGroup 'Context' { Write-Host ($context | Format-List | Out-String) } - } - AfterAll { - Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent - Write-Host ('-' * 60) - } - - # Tests for APP goes here - if ($AuthType -eq 'APP') { - It 'Connect-GitHubApp - Connects as a GitHub App to ' { + if ($AuthType -eq 'APP') { $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent LogGroup 'Context' { Write-Host ($context | Format-List | Out-String) } } } + AfterAll { + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent + Write-Host ('-' * 60) + } - # Tests for runners goes here - if ($Type -eq 'GitHub Actions') {} - - # Tests for IAT UAT and PAT goes here It 'Get-GitHubEmoji - Gets a list of all emojis' { $emojis = Get-GitHubEmoji LogGroup 'emojis' { diff --git a/tests/Users.Tests.ps1 b/tests/Users.Tests.ps1 index f4cb7cc32..d3d7247da 100644 --- a/tests/Users.Tests.ps1 +++ b/tests/Users.Tests.ps1 @@ -24,23 +24,18 @@ Describe 'Users' { LogGroup 'Context' { Write-Host ($context | Format-List | Out-String) } - } - AfterAll { - Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent - Write-Host ('-' * 60) - } - - # Tests for APP goes here - if ($AuthType -eq 'APP') { - It 'Connect-GitHubApp - Connects as a GitHub App to ' { + if ($AuthType -eq 'APP') { $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent LogGroup 'Context' { Write-Host ($context | Format-List | Out-String) } } } + AfterAll { + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent + Write-Host ('-' * 60) + } - # Tests for IAT UAT and PAT goes here It 'Get-GitHubUser - Get the specified user' { { Get-GitHubUser -Name 'Octocat' } | Should -Not -Throw } From 333143d533b23ca6053524b9ec1806bdaebce84b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 6 Jan 2026 17:26:58 +0100 Subject: [PATCH 07/10] Reset the tests and clear the AfterAll and BeforeAll files. --- tests/AfterAll.ps1 | 284 +------------------------------------ tests/BeforeAll.ps1 | 280 +----------------------------------- tests/Enterprise.Tests.ps1 | 4 - 3 files changed, 3 insertions(+), 565 deletions(-) diff --git a/tests/AfterAll.ps1 b/tests/AfterAll.ps1 index a88e3f47c..14e6a1a48 100644 --- a/tests/AfterAll.ps1 +++ b/tests/AfterAll.ps1 @@ -1,286 +1,6 @@ -<# -.SYNOPSIS - Global teardown script that runs once after all parallel tests complete. - -.DESCRIPTION - This script is executed by the Process-PSModule workflow after all tests have run. - It performs final cleanup tasks to ensure no test artifacts are left behind: - - Removes any remaining test resources that weren't cleaned up by individual tests - - Generates a final cleanup report - - Helps prevent resource accumulation from failed tests - - Individual test files handle their own cleanup in AfterAll blocks, but this - provides a safety net for any resources that might have been missed. - -.NOTES - This script is called automatically by Process-PSModule workflow. - It uses the same cleanup logic as BeforeAll.ps1 to ensure consistent cleanup. -#> - -[CmdletBinding()] +[CmdletBinding()] param() -$ErrorActionPreference = 'Continue' -$WarningPreference = 'Continue' - LogGroup 'AfterAll - Global Test Teardown' { - Write-Host "Starting global test teardown at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" - Write-Host "Runner OS: $env:RUNNER_OS" - Write-Host "GitHub Actions: $env:GITHUB_ACTIONS" - - # Track statistics - $stats = @{ - RepositoriesRemoved = 0 - TeamsRemoved = 0 - EnvironmentsRemoved = 0 - SecretsRemoved = 0 - VariablesRemoved = 0 - AppInstallationsRemoved = 0 - Errors = 0 - } - - # Test name prefixes used across test files - $testPrefixes = @( - 'RepositoriesTests' - 'TeamsTests' - 'EnvironmentsTests' - 'SecretsTests' - 'VariablesTests' - 'AppsTests' - 'ArtifactsTests' - 'ReleasesTests' - 'PermissionsTests' - 'MsxOrgTests' - 'GitHubTests' - ) - - # Get all authentication scenarios - $authCases = . "$PSScriptRoot/Data/AuthCases.ps1" - - Write-Host "`nPerforming final cleanup of test resources..." - Write-Host "Test prefixes to clean: $($testPrefixes -join ', ')" - - # Process each auth case to clean up remaining resources - foreach ($authCase in $authCases) { - $owner = $authCase.Owner - $ownerType = $authCase.OwnerType - $tokenType = $authCase.TokenType - $authType = $authCase.AuthType - - LogGroup "Final Cleanup - $owner ($ownerType) using $tokenType" { - try { - # Connect to GitHub - Write-Host "Connecting to GitHub as $owner..." - $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop - Write-Host "Connected as: $($context.Login)" - - # For APP auth, also connect to the app installation - if ($authType -eq 'APP') { - Write-Host "Connecting to GitHub App installation..." - $context = Connect-GitHubApp @authCase.ConnectAppParams -PassThru -Default -Silent -ErrorAction Stop - Write-Host "Connected to installation: $($context.Installation.ID)" - } - - # Clean up repositories - Write-Host "Checking for remaining repositories..." - try { - $repos = switch ($ownerType) { - 'user' { - Get-GitHubRepository -ErrorAction SilentlyContinue | - Where-Object { - $repoName = $_.Name - $testPrefixes | Where-Object { $repoName -like "$_-*" } - } - } - 'organization' { - Get-GitHubRepository -Organization $owner -ErrorAction SilentlyContinue | - Where-Object { - $repoName = $_.Name - $testPrefixes | Where-Object { $repoName -like "$_-*" } - } - } - default { @() } - } - - if ($repos) { - Write-Host "Found $($repos.Count) repositories to remove" - foreach ($repo in $repos) { - try { - Write-Host " Removing repository: $($repo.FullName)" - $repo | Remove-GitHubRepository -Confirm:$false -ErrorAction Stop - $stats.RepositoriesRemoved++ - } catch { - Write-Warning " Failed to remove repository $($repo.FullName): $_" - $stats.Errors++ - } - } - } else { - Write-Host "No repositories found (good - tests cleaned up after themselves)" - } - } catch { - Write-Warning "Error cleaning repositories: $_" - $stats.Errors++ - } - - # Clean up teams (organization only) - if ($ownerType -eq 'organization') { - Write-Host "Checking for remaining teams..." - try { - $teams = Get-GitHubTeam -Organization $owner -ErrorAction SilentlyContinue | - Where-Object { - $teamName = $_.Name - $testPrefixes | Where-Object { $teamName -like "$_*" } - } - - if ($teams) { - Write-Host "Found $($teams.Count) teams to remove" - foreach ($team in $teams) { - try { - Write-Host " Removing team: $($team.Name)" - $team | Remove-GitHubTeam -Confirm:$false -ErrorAction Stop - $stats.TeamsRemoved++ - } catch { - Write-Warning " Failed to remove team $($team.Name): $_" - $stats.Errors++ - } - } - } else { - Write-Host "No teams found (good - tests cleaned up after themselves)" - } - } catch { - Write-Warning "Error cleaning teams: $_" - $stats.Errors++ - } - - # Clean up organization secrets - Write-Host "Checking for remaining organization secrets..." - try { - $secrets = Get-GitHubSecret -Owner $owner -ErrorAction SilentlyContinue | - Where-Object { - $secretName = $_.Name - $testPrefixes | Where-Object { $secretName -like "$_*" } - } - - if ($secrets) { - Write-Host "Found $($secrets.Count) secrets to remove" - foreach ($secret in $secrets) { - try { - Write-Host " Removing secret: $($secret.Name)" - $secret | Remove-GitHubSecret -ErrorAction Stop - $stats.SecretsRemoved++ - } catch { - Write-Warning " Failed to remove secret $($secret.Name): $_" - $stats.Errors++ - } - } - } else { - Write-Host "No secrets found (good - tests cleaned up after themselves)" - } - } catch { - Write-Warning "Error cleaning secrets: $_" - $stats.Errors++ - } - - # Clean up organization variables - Write-Host "Checking for remaining organization variables..." - try { - $variables = Get-GitHubVariable -Owner $owner -ErrorAction SilentlyContinue | - Where-Object { - $variableName = $_.Name - $testPrefixes | Where-Object { $variableName -like "$_*" } - } - - if ($variables) { - Write-Host "Found $($variables.Count) variables to remove" - foreach ($variable in $variables) { - try { - Write-Host " Removing variable: $($variable.Name)" - $variable | Remove-GitHubVariable -ErrorAction Stop - $stats.VariablesRemoved++ - } catch { - Write-Warning " Failed to remove variable $($variable.Name): $_" - $stats.Errors++ - } - } - } else { - Write-Host "No variables found (good - tests cleaned up after themselves)" - } - } catch { - Write-Warning "Error cleaning variables: $_" - $stats.Errors++ - } - } - - # Clean up app installations (APP auth only) - if ($authType -eq 'APP') { - Write-Host "Checking for remaining app installations..." - try { - # Reconnect as the app (not installation) to manage installations - Disconnect-GitHubAccount -Silent - $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop - Write-Host "Reconnected as app: $($context.ClientID)" - - $installations = Get-GitHubAppInstallation -ErrorAction SilentlyContinue | - Where-Object { - $targetName = $_.Target.Name - $testPrefixes | Where-Object { $targetName -like "$_*" } - } - - if ($installations) { - Write-Host "Found $($installations.Count) app installations to remove" - foreach ($installation in $installations) { - try { - Write-Host " Uninstalling from: $($installation.Target.Name)" - $installation | Uninstall-GitHubApp -Confirm:$false -ErrorAction Stop - $stats.AppInstallationsRemoved++ - } catch { - Write-Warning " Failed to uninstall from $($installation.Target.Name): $_" - $stats.Errors++ - } - } - } else { - Write-Host "No app installations found (good - tests cleaned up after themselves)" - } - } catch { - Write-Warning "Error cleaning app installations: $_" - $stats.Errors++ - } - } - - # Disconnect after cleanup - Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent - - } catch { - Write-Warning "Failed to process $owner ($ownerType): $_" - $stats.Errors++ - # Ensure we disconnect even on error - Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent - } - } - } - - # Report cleanup statistics - LogGroup 'Final Cleanup Summary' { - Write-Host "`nGlobal test teardown completed at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" - Write-Host "Final Cleanup Statistics:" - Write-Host " Repositories removed: $($stats.RepositoriesRemoved)" - Write-Host " Teams removed: $($stats.TeamsRemoved)" - Write-Host " Environments removed: $($stats.EnvironmentsRemoved)" - Write-Host " Secrets removed: $($stats.SecretsRemoved)" - Write-Host " Variables removed: $($stats.VariablesRemoved)" - Write-Host " App installations removed: $($stats.AppInstallationsRemoved)" - Write-Host " Errors encountered: $($stats.Errors)" - Write-Host "" - - if ($stats.RepositoriesRemoved -eq 0 -and $stats.TeamsRemoved -eq 0 -and - $stats.SecretsRemoved -eq 0 -and $stats.VariablesRemoved -eq 0) { - Write-Host "✓ Excellent! All tests cleaned up their resources properly." - } elseif ($stats.Errors -eq 0) { - Write-Host "✓ Final cleanup completed successfully. Some resources were left behind by tests." - } else { - Write-Warning "Some cleanup operations failed. Manual cleanup may be required." - } - } + } - -Write-Host "AfterAll.ps1 completed" diff --git a/tests/BeforeAll.ps1 b/tests/BeforeAll.ps1 index 8d242e2b5..9d7f7caf9 100644 --- a/tests/BeforeAll.ps1 +++ b/tests/BeforeAll.ps1 @@ -1,284 +1,6 @@ -<# -.SYNOPSIS - Global setup script that runs once before all parallel tests. - -.DESCRIPTION - This script is executed by the Process-PSModule workflow before any tests run. - It performs infrastructure setup tasks that benefit all test runs: - - Cleans up stale resources from previous failed test runs - - Reduces rate limiting by removing orphaned test artifacts upfront - - Individual test files still handle their own: - - Authentication (Connect-GitHubAccount, Connect-GitHubApp) - - Resource creation (repositories, teams, environments) - - Resource cleanup (in their AfterAll blocks) - -.NOTES - This script is called automatically by Process-PSModule workflow. - Tests continue to create their own isolated resources to support parallel execution. -#> - -[CmdletBinding()] +[CmdletBinding()] param() -$ErrorActionPreference = 'Continue' -$WarningPreference = 'Continue' - LogGroup 'BeforeAll - Global Test Setup' { - Write-Host "Starting global test setup at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" - Write-Host "Runner OS: $env:RUNNER_OS" - Write-Host "GitHub Actions: $env:GITHUB_ACTIONS" - - # Track statistics - $stats = @{ - RepositoriesRemoved = 0 - TeamsRemoved = 0 - EnvironmentsRemoved = 0 - SecretsRemoved = 0 - VariablesRemoved = 0 - AppInstallationsRemoved = 0 - Errors = 0 - } - - # Test name prefixes used across test files - $testPrefixes = @( - 'RepositoriesTests' - 'TeamsTests' - 'EnvironmentsTests' - 'SecretsTests' - 'VariablesTests' - 'AppsTests' - 'ArtifactsTests' - 'ReleasesTests' - 'PermissionsTests' - 'MsxOrgTests' - 'GitHubTests' - ) - - # Get all authentication scenarios - $authCases = . "$PSScriptRoot/Data/AuthCases.ps1" - - Write-Host "`nCleaning up stale resources from previous test runs..." - Write-Host "Test prefixes to clean: $($testPrefixes -join ', ')" - - # Process each auth case to clean up stale resources - foreach ($authCase in $authCases) { - $owner = $authCase.Owner - $ownerType = $authCase.OwnerType - $tokenType = $authCase.TokenType - $authType = $authCase.AuthType - - LogGroup "Cleanup - $owner ($ownerType) using $tokenType" { - try { - # Connect to GitHub - Write-Host "Connecting to GitHub as $owner..." - $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop - Write-Host "Connected as: $($context.Login)" - - # For APP auth, also connect to the app installation - if ($authType -eq 'APP') { - Write-Host "Connecting to GitHub App installation..." - $context = Connect-GitHubApp @authCase.ConnectAppParams -PassThru -Default -Silent -ErrorAction Stop - Write-Host "Connected to installation: $($context.Installation.ID)" - } - - # Clean up repositories - Write-Host "Checking for stale repositories..." - try { - $repos = switch ($ownerType) { - 'user' { - Get-GitHubRepository -ErrorAction SilentlyContinue | - Where-Object { - $repoName = $_.Name - $testPrefixes | Where-Object { $repoName -like "$_-*" } - } - } - 'organization' { - Get-GitHubRepository -Organization $owner -ErrorAction SilentlyContinue | - Where-Object { - $repoName = $_.Name - $testPrefixes | Where-Object { $repoName -like "$_-*" } - } - } - default { @() } - } - - if ($repos) { - Write-Host "Found $($repos.Count) stale repositories to remove" - foreach ($repo in $repos) { - try { - Write-Host " Removing repository: $($repo.FullName)" - $repo | Remove-GitHubRepository -Confirm:$false -ErrorAction Stop - $stats.RepositoriesRemoved++ - } catch { - Write-Warning " Failed to remove repository $($repo.FullName): $_" - $stats.Errors++ - } - } - } else { - Write-Host "No stale repositories found" - } - } catch { - Write-Warning "Error cleaning repositories: $_" - $stats.Errors++ - } - # Clean up teams (organization only) - if ($ownerType -eq 'organization') { - Write-Host "Checking for stale teams..." - try { - $teams = Get-GitHubTeam -Organization $owner -ErrorAction SilentlyContinue | - Where-Object { - $teamName = $_.Name - $testPrefixes | Where-Object { $teamName -like "$_*" } - } - - if ($teams) { - Write-Host "Found $($teams.Count) stale teams to remove" - foreach ($team in $teams) { - try { - Write-Host " Removing team: $($team.Name)" - $team | Remove-GitHubTeam -Confirm:$false -ErrorAction Stop - $stats.TeamsRemoved++ - } catch { - Write-Warning " Failed to remove team $($team.Name): $_" - $stats.Errors++ - } - } - } else { - Write-Host "No stale teams found" - } - } catch { - Write-Warning "Error cleaning teams: $_" - $stats.Errors++ - } - - # Clean up organization secrets - Write-Host "Checking for stale organization secrets..." - try { - $secrets = Get-GitHubSecret -Owner $owner -ErrorAction SilentlyContinue | - Where-Object { - $secretName = $_.Name - $testPrefixes | Where-Object { $secretName -like "$_*" } - } - - if ($secrets) { - Write-Host "Found $($secrets.Count) stale secrets to remove" - foreach ($secret in $secrets) { - try { - Write-Host " Removing secret: $($secret.Name)" - $secret | Remove-GitHubSecret -ErrorAction Stop - $stats.SecretsRemoved++ - } catch { - Write-Warning " Failed to remove secret $($secret.Name): $_" - $stats.Errors++ - } - } - } else { - Write-Host "No stale secrets found" - } - } catch { - Write-Warning "Error cleaning secrets: $_" - $stats.Errors++ - } - - # Clean up organization variables - Write-Host "Checking for stale organization variables..." - try { - $variables = Get-GitHubVariable -Owner $owner -ErrorAction SilentlyContinue | - Where-Object { - $variableName = $_.Name - $testPrefixes | Where-Object { $variableName -like "$_*" } - } - - if ($variables) { - Write-Host "Found $($variables.Count) stale variables to remove" - foreach ($variable in $variables) { - try { - Write-Host " Removing variable: $($variable.Name)" - $variable | Remove-GitHubVariable -ErrorAction Stop - $stats.VariablesRemoved++ - } catch { - Write-Warning " Failed to remove variable $($variable.Name): $_" - $stats.Errors++ - } - } - } else { - Write-Host "No stale variables found" - } - } catch { - Write-Warning "Error cleaning variables: $_" - $stats.Errors++ - } - } - - # Clean up app installations (APP auth only) - if ($authType -eq 'APP') { - Write-Host "Checking for stale app installations..." - try { - # Reconnect as the app (not installation) to manage installations - Disconnect-GitHubAccount -Silent - $context = Connect-GitHubAccount @authCase.ConnectParams -PassThru -Silent -ErrorAction Stop - Write-Host "Reconnected as app: $($context.ClientID)" - - $installations = Get-GitHubAppInstallation -ErrorAction SilentlyContinue | - Where-Object { - $targetName = $_.Target.Name - $testPrefixes | Where-Object { $targetName -like "$_*" } - } - - if ($installations) { - Write-Host "Found $($installations.Count) stale app installations to remove" - foreach ($installation in $installations) { - try { - Write-Host " Uninstalling from: $($installation.Target.Name)" - $installation | Uninstall-GitHubApp -Confirm:$false -ErrorAction Stop - $stats.AppInstallationsRemoved++ - } catch { - Write-Warning " Failed to uninstall from $($installation.Target.Name): $_" - $stats.Errors++ - } - } - } else { - Write-Host "No stale app installations found" - } - } catch { - Write-Warning "Error cleaning app installations: $_" - $stats.Errors++ - } - } - - # Disconnect after cleanup - Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent - - } catch { - Write-Warning "Failed to process $owner ($ownerType): $_" - $stats.Errors++ - # Ensure we disconnect even on error - Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent - } - } - } - - # Report cleanup statistics - LogGroup 'Cleanup Summary' { - Write-Host "`nGlobal test setup completed at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" - Write-Host "Cleanup Statistics:" - Write-Host " Repositories removed: $($stats.RepositoriesRemoved)" - Write-Host " Teams removed: $($stats.TeamsRemoved)" - Write-Host " Environments removed: $($stats.EnvironmentsRemoved)" - Write-Host " Secrets removed: $($stats.SecretsRemoved)" - Write-Host " Variables removed: $($stats.VariablesRemoved)" - Write-Host " App installations removed: $($stats.AppInstallationsRemoved)" - Write-Host " Errors encountered: $($stats.Errors)" - Write-Host "" - - if ($stats.Errors -gt 0) { - Write-Warning "Some cleanup operations failed. Tests may encounter issues with existing resources." - } else { - Write-Host "All cleanup operations completed successfully." - } - } } - -Write-Host "BeforeAll.ps1 completed" diff --git a/tests/Enterprise.Tests.ps1 b/tests/Enterprise.Tests.ps1 index b6b7a73dd..df7444c43 100644 --- a/tests/Enterprise.Tests.ps1 +++ b/tests/Enterprise.Tests.ps1 @@ -19,10 +19,6 @@ [CmdletBinding()] param() -BeforeAll { - # DEFAULTS ACCROSS ALL TESTS -} - Describe 'Template' { $authCases = . "$PSScriptRoot/Data/AuthCases.ps1" From 8867fe7584a949c648c4c8a96b239de725e11fa5 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 12 Jan 2026 22:34:47 +0100 Subject: [PATCH 08/10] Add initial Pester tests for GitHub API interactions - Created TEMPLATE.ps1 for structuring tests with Pester. - Implemented Teams.Tests.ps1 to test GitHub Teams API functionalities including team creation, retrieval, updating, and deletion. - Developed Users.Tests.ps1 to validate user-related API calls, including user retrieval and updates. - Added Variables.Tests.ps1 to test GitHub variable management across different scopes (organization, repository, environment). - Included necessary suppressions for Pester warnings and established logging for better output visibility during test execution. --- tests/AfterAll.ps1 | 13 +++++++- tests/BeforeAll.ps1 | 36 +++++++++++++++++++++++ tests/Environments.Tests.ps1 | 29 ++++-------------- tests/{ => tmp}/Apps.Tests.ps1 | 0 tests/{ => tmp}/Artifacts.Tests.ps1 | 0 tests/{ => tmp}/Emojis.Tests.ps1 | 0 tests/{ => tmp}/Enterprise.Tests.ps1 | 0 tests/{ => tmp}/GitHub.Tests.ps1 | 0 tests/{ => tmp}/GitHubFormatter.Tests.ps1 | 0 tests/{ => tmp}/Organizations.Tests.ps1 | 0 tests/{ => tmp}/Permissions.Tests.ps1 | 0 tests/{ => tmp}/README-SETUP-TEARDOWN.md | 0 tests/{ => tmp}/README.md | 0 tests/{ => tmp}/Releases.Tests.ps1 | 0 tests/{ => tmp}/Repositories.Tests.ps1 | 0 tests/{ => tmp}/Secrets.Tests.ps1 | 0 tests/{ => tmp}/TEMPLATE.ps1 | 0 tests/{ => tmp}/Teams.Tests.ps1 | 0 tests/{ => tmp}/Users.Tests.ps1 | 0 tests/{ => tmp}/Variables.Tests.ps1 | 0 20 files changed, 54 insertions(+), 24 deletions(-) rename tests/{ => tmp}/Apps.Tests.ps1 (100%) rename tests/{ => tmp}/Artifacts.Tests.ps1 (100%) rename tests/{ => tmp}/Emojis.Tests.ps1 (100%) rename tests/{ => tmp}/Enterprise.Tests.ps1 (100%) rename tests/{ => tmp}/GitHub.Tests.ps1 (100%) rename tests/{ => tmp}/GitHubFormatter.Tests.ps1 (100%) rename tests/{ => tmp}/Organizations.Tests.ps1 (100%) rename tests/{ => tmp}/Permissions.Tests.ps1 (100%) rename tests/{ => tmp}/README-SETUP-TEARDOWN.md (100%) rename tests/{ => tmp}/README.md (100%) rename tests/{ => tmp}/Releases.Tests.ps1 (100%) rename tests/{ => tmp}/Repositories.Tests.ps1 (100%) rename tests/{ => tmp}/Secrets.Tests.ps1 (100%) rename tests/{ => tmp}/TEMPLATE.ps1 (100%) rename tests/{ => tmp}/Teams.Tests.ps1 (100%) rename tests/{ => tmp}/Users.Tests.ps1 (100%) rename tests/{ => tmp}/Variables.Tests.ps1 (100%) diff --git a/tests/AfterAll.ps1 b/tests/AfterAll.ps1 index 14e6a1a48..c872e9bc6 100644 --- a/tests/AfterAll.ps1 +++ b/tests/AfterAll.ps1 @@ -2,5 +2,16 @@ param() LogGroup 'AfterAll - Global Test Teardown' { - + + + switch ($OwnerType) { + 'user' { + Get-GitHubRepository | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false + } + 'organization' { + Get-GitHubRepository -Organization $Owner | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false + } + } + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent + Write-Host ('-' * 60) } diff --git a/tests/BeforeAll.ps1 b/tests/BeforeAll.ps1 index 9d7f7caf9..6b7d1de44 100644 --- a/tests/BeforeAll.ps1 +++ b/tests/BeforeAll.ps1 @@ -2,5 +2,41 @@ param() LogGroup 'BeforeAll - Global Test Setup' { + $authCases = . "$PSScriptRoot/Data/AuthCases.ps1" + $prefix = 'Test' + $os = $env:RUNNER_OS + $id = $env:GITHUB_RUN_ID + + foreach ($authCase in $authCases) { + $authCase.GetEnumerator() | ForEach-Object { Set-Variable -Name $_.Key -Value $_.Value } + + LogGroup 'Repository setup' { + $context = Connect-GitHubAccount @connectParams -PassThru -Silent + Write-Host ($context | Out-String) + if ($AuthType -eq 'APP') { + $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent + Write-Host ($context | Format-List | Out-String) + } + + $repoPrefix = "$prefix-$os-$TokenType" + $repoName = "$repoPrefix-$id" + + switch ($OwnerType) { + 'user' { + Get-GitHubRepository | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false + New-GitHubRepository -Name $repoName -Confirm:$false + } + 'organization' { + Get-GitHubRepository -Organization $Owner | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false + New-GitHubRepository -Organization $Owner -Name $repoName -Confirm:$false + } + } + } + LogGroup 'Environment setup' { + $environmentName = "$prefix-$os-$TokenType-$id" + } + LogGroup 'Variables setup' {} + LogGroup 'Secrets setup' {} + } } diff --git a/tests/Environments.Tests.ps1 b/tests/Environments.Tests.ps1 index 762eab550..3a4794270 100644 --- a/tests/Environments.Tests.ps1 +++ b/tests/Environments.Tests.ps1 @@ -22,7 +22,7 @@ param() BeforeAll { $testName = 'EnvironmentsTests' $os = $env:RUNNER_OS - $guid = [guid]::NewGuid().ToString() + $id = $env:GITHUB_RUN_ID } Describe 'Environments' { @@ -40,34 +40,17 @@ Describe 'Environments' { Write-Host ($context | Format-List | Out-String) } } - $repoPrefix = "$testName-$os-$TokenType" - $repoName = "$repoPrefix-$guid" - $environmentName = "$testName-$os-$TokenType-$guid" + $repoPrefix = "Test-$os-$TokenType" + $repoName = "$repoPrefix-$id" + $environmentName = "$testName-$os-$TokenType-$id" - switch ($OwnerType) { - 'user' { - Get-GitHubRepository | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false - $repo = New-GitHubRepository -Name $repoName -Confirm:$false - } - 'organization' { - Get-GitHubRepository -Organization $Owner | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false - $repo = New-GitHubRepository -Organization $owner -Name $repoName -Confirm:$false - } - } - LogGroup "Repository - [$repoName]" { + LogGroup "Using Repository - [$repoName]" { + $repo = Get-GitHubRepository -Owner $Owner -Repository $repoName Write-Host ($repo | Select-Object * | Out-String) } } AfterAll { - switch ($OwnerType) { - 'user' { - Get-GitHubRepository | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false - } - 'organization' { - Get-GitHubRepository -Organization $Owner | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false - } - } Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent Write-Host ('-' * 60) } diff --git a/tests/Apps.Tests.ps1 b/tests/tmp/Apps.Tests.ps1 similarity index 100% rename from tests/Apps.Tests.ps1 rename to tests/tmp/Apps.Tests.ps1 diff --git a/tests/Artifacts.Tests.ps1 b/tests/tmp/Artifacts.Tests.ps1 similarity index 100% rename from tests/Artifacts.Tests.ps1 rename to tests/tmp/Artifacts.Tests.ps1 diff --git a/tests/Emojis.Tests.ps1 b/tests/tmp/Emojis.Tests.ps1 similarity index 100% rename from tests/Emojis.Tests.ps1 rename to tests/tmp/Emojis.Tests.ps1 diff --git a/tests/Enterprise.Tests.ps1 b/tests/tmp/Enterprise.Tests.ps1 similarity index 100% rename from tests/Enterprise.Tests.ps1 rename to tests/tmp/Enterprise.Tests.ps1 diff --git a/tests/GitHub.Tests.ps1 b/tests/tmp/GitHub.Tests.ps1 similarity index 100% rename from tests/GitHub.Tests.ps1 rename to tests/tmp/GitHub.Tests.ps1 diff --git a/tests/GitHubFormatter.Tests.ps1 b/tests/tmp/GitHubFormatter.Tests.ps1 similarity index 100% rename from tests/GitHubFormatter.Tests.ps1 rename to tests/tmp/GitHubFormatter.Tests.ps1 diff --git a/tests/Organizations.Tests.ps1 b/tests/tmp/Organizations.Tests.ps1 similarity index 100% rename from tests/Organizations.Tests.ps1 rename to tests/tmp/Organizations.Tests.ps1 diff --git a/tests/Permissions.Tests.ps1 b/tests/tmp/Permissions.Tests.ps1 similarity index 100% rename from tests/Permissions.Tests.ps1 rename to tests/tmp/Permissions.Tests.ps1 diff --git a/tests/README-SETUP-TEARDOWN.md b/tests/tmp/README-SETUP-TEARDOWN.md similarity index 100% rename from tests/README-SETUP-TEARDOWN.md rename to tests/tmp/README-SETUP-TEARDOWN.md diff --git a/tests/README.md b/tests/tmp/README.md similarity index 100% rename from tests/README.md rename to tests/tmp/README.md diff --git a/tests/Releases.Tests.ps1 b/tests/tmp/Releases.Tests.ps1 similarity index 100% rename from tests/Releases.Tests.ps1 rename to tests/tmp/Releases.Tests.ps1 diff --git a/tests/Repositories.Tests.ps1 b/tests/tmp/Repositories.Tests.ps1 similarity index 100% rename from tests/Repositories.Tests.ps1 rename to tests/tmp/Repositories.Tests.ps1 diff --git a/tests/Secrets.Tests.ps1 b/tests/tmp/Secrets.Tests.ps1 similarity index 100% rename from tests/Secrets.Tests.ps1 rename to tests/tmp/Secrets.Tests.ps1 diff --git a/tests/TEMPLATE.ps1 b/tests/tmp/TEMPLATE.ps1 similarity index 100% rename from tests/TEMPLATE.ps1 rename to tests/tmp/TEMPLATE.ps1 diff --git a/tests/Teams.Tests.ps1 b/tests/tmp/Teams.Tests.ps1 similarity index 100% rename from tests/Teams.Tests.ps1 rename to tests/tmp/Teams.Tests.ps1 diff --git a/tests/Users.Tests.ps1 b/tests/tmp/Users.Tests.ps1 similarity index 100% rename from tests/Users.Tests.ps1 rename to tests/tmp/Users.Tests.ps1 diff --git a/tests/Variables.Tests.ps1 b/tests/tmp/Variables.Tests.ps1 similarity index 100% rename from tests/Variables.Tests.ps1 rename to tests/tmp/Variables.Tests.ps1 From 6869f4ae12f363a9351550192ea32b27cdd9c167 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 12 Jan 2026 22:56:00 +0100 Subject: [PATCH 09/10] Add Pester tests for GitHub API interactions - Created TEMPLATE.ps1 for structuring Pester tests with common setup. - Implemented Teams.Tests.ps1 to test GitHub Teams API functionalities including team creation, retrieval, updating, and deletion. - Developed Users.Tests.ps1 to validate user-related API calls, including user retrieval and updates. - Added Variables.Tests.ps1 to test GitHub repository and organization variable management, including creation, updating, and removal of variables. --- {tests/tmp => tmp}/Apps.Tests.ps1 | 0 {tests/tmp => tmp}/Artifacts.Tests.ps1 | 0 {tests/tmp => tmp}/Emojis.Tests.ps1 | 0 {tests/tmp => tmp}/Enterprise.Tests.ps1 | 0 {tests/tmp => tmp}/GitHub.Tests.ps1 | 0 {tests/tmp => tmp}/GitHubFormatter.Tests.ps1 | 0 {tests/tmp => tmp}/Organizations.Tests.ps1 | 0 {tests/tmp => tmp}/Permissions.Tests.ps1 | 0 {tests/tmp => tmp}/README-SETUP-TEARDOWN.md | 0 {tests/tmp => tmp}/README.md | 0 {tests/tmp => tmp}/Releases.Tests.ps1 | 0 {tests/tmp => tmp}/Repositories.Tests.ps1 | 0 {tests/tmp => tmp}/Secrets.Tests.ps1 | 0 {tests/tmp => tmp}/TEMPLATE.ps1 | 0 {tests/tmp => tmp}/Teams.Tests.ps1 | 0 {tests/tmp => tmp}/Users.Tests.ps1 | 0 {tests/tmp => tmp}/Variables.Tests.ps1 | 0 17 files changed, 0 insertions(+), 0 deletions(-) rename {tests/tmp => tmp}/Apps.Tests.ps1 (100%) rename {tests/tmp => tmp}/Artifacts.Tests.ps1 (100%) rename {tests/tmp => tmp}/Emojis.Tests.ps1 (100%) rename {tests/tmp => tmp}/Enterprise.Tests.ps1 (100%) rename {tests/tmp => tmp}/GitHub.Tests.ps1 (100%) rename {tests/tmp => tmp}/GitHubFormatter.Tests.ps1 (100%) rename {tests/tmp => tmp}/Organizations.Tests.ps1 (100%) rename {tests/tmp => tmp}/Permissions.Tests.ps1 (100%) rename {tests/tmp => tmp}/README-SETUP-TEARDOWN.md (100%) rename {tests/tmp => tmp}/README.md (100%) rename {tests/tmp => tmp}/Releases.Tests.ps1 (100%) rename {tests/tmp => tmp}/Repositories.Tests.ps1 (100%) rename {tests/tmp => tmp}/Secrets.Tests.ps1 (100%) rename {tests/tmp => tmp}/TEMPLATE.ps1 (100%) rename {tests/tmp => tmp}/Teams.Tests.ps1 (100%) rename {tests/tmp => tmp}/Users.Tests.ps1 (100%) rename {tests/tmp => tmp}/Variables.Tests.ps1 (100%) diff --git a/tests/tmp/Apps.Tests.ps1 b/tmp/Apps.Tests.ps1 similarity index 100% rename from tests/tmp/Apps.Tests.ps1 rename to tmp/Apps.Tests.ps1 diff --git a/tests/tmp/Artifacts.Tests.ps1 b/tmp/Artifacts.Tests.ps1 similarity index 100% rename from tests/tmp/Artifacts.Tests.ps1 rename to tmp/Artifacts.Tests.ps1 diff --git a/tests/tmp/Emojis.Tests.ps1 b/tmp/Emojis.Tests.ps1 similarity index 100% rename from tests/tmp/Emojis.Tests.ps1 rename to tmp/Emojis.Tests.ps1 diff --git a/tests/tmp/Enterprise.Tests.ps1 b/tmp/Enterprise.Tests.ps1 similarity index 100% rename from tests/tmp/Enterprise.Tests.ps1 rename to tmp/Enterprise.Tests.ps1 diff --git a/tests/tmp/GitHub.Tests.ps1 b/tmp/GitHub.Tests.ps1 similarity index 100% rename from tests/tmp/GitHub.Tests.ps1 rename to tmp/GitHub.Tests.ps1 diff --git a/tests/tmp/GitHubFormatter.Tests.ps1 b/tmp/GitHubFormatter.Tests.ps1 similarity index 100% rename from tests/tmp/GitHubFormatter.Tests.ps1 rename to tmp/GitHubFormatter.Tests.ps1 diff --git a/tests/tmp/Organizations.Tests.ps1 b/tmp/Organizations.Tests.ps1 similarity index 100% rename from tests/tmp/Organizations.Tests.ps1 rename to tmp/Organizations.Tests.ps1 diff --git a/tests/tmp/Permissions.Tests.ps1 b/tmp/Permissions.Tests.ps1 similarity index 100% rename from tests/tmp/Permissions.Tests.ps1 rename to tmp/Permissions.Tests.ps1 diff --git a/tests/tmp/README-SETUP-TEARDOWN.md b/tmp/README-SETUP-TEARDOWN.md similarity index 100% rename from tests/tmp/README-SETUP-TEARDOWN.md rename to tmp/README-SETUP-TEARDOWN.md diff --git a/tests/tmp/README.md b/tmp/README.md similarity index 100% rename from tests/tmp/README.md rename to tmp/README.md diff --git a/tests/tmp/Releases.Tests.ps1 b/tmp/Releases.Tests.ps1 similarity index 100% rename from tests/tmp/Releases.Tests.ps1 rename to tmp/Releases.Tests.ps1 diff --git a/tests/tmp/Repositories.Tests.ps1 b/tmp/Repositories.Tests.ps1 similarity index 100% rename from tests/tmp/Repositories.Tests.ps1 rename to tmp/Repositories.Tests.ps1 diff --git a/tests/tmp/Secrets.Tests.ps1 b/tmp/Secrets.Tests.ps1 similarity index 100% rename from tests/tmp/Secrets.Tests.ps1 rename to tmp/Secrets.Tests.ps1 diff --git a/tests/tmp/TEMPLATE.ps1 b/tmp/TEMPLATE.ps1 similarity index 100% rename from tests/tmp/TEMPLATE.ps1 rename to tmp/TEMPLATE.ps1 diff --git a/tests/tmp/Teams.Tests.ps1 b/tmp/Teams.Tests.ps1 similarity index 100% rename from tests/tmp/Teams.Tests.ps1 rename to tmp/Teams.Tests.ps1 diff --git a/tests/tmp/Users.Tests.ps1 b/tmp/Users.Tests.ps1 similarity index 100% rename from tests/tmp/Users.Tests.ps1 rename to tmp/Users.Tests.ps1 diff --git a/tests/tmp/Variables.Tests.ps1 b/tmp/Variables.Tests.ps1 similarity index 100% rename from tests/tmp/Variables.Tests.ps1 rename to tmp/Variables.Tests.ps1 From 9e41346f296c9c4153b67ed74b34157360351525 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 13 Jan 2026 00:11:30 +0100 Subject: [PATCH 10/10] Refactor: Add structure to Variables and Secrets setup log groups --- tests/BeforeAll.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/BeforeAll.ps1 b/tests/BeforeAll.ps1 index 6b7d1de44..81208c9e2 100644 --- a/tests/BeforeAll.ps1 +++ b/tests/BeforeAll.ps1 @@ -36,7 +36,11 @@ LogGroup 'BeforeAll - Global Test Setup' { LogGroup 'Environment setup' { $environmentName = "$prefix-$os-$TokenType-$id" } - LogGroup 'Variables setup' {} - LogGroup 'Secrets setup' {} + LogGroup 'Variables setup' { + + } + LogGroup 'Secrets setup' { + + } } }