Skip to content

🩹 [Patch]: Consolidate test setup/teardown tasks#541

Draft
Copilot wants to merge 17 commits intomainfrom
copilot/consolidate-test-setup-tasks
Draft

🩹 [Patch]: Consolidate test setup/teardown tasks#541
Copilot wants to merge 17 commits intomainfrom
copilot/consolidate-test-setup-tasks

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

Test infrastructure now uses shared global setup and teardown scripts (BeforeAll.ps1 / AfterAll.ps1) that run once before and after all parallel test jobs. This reduces duplicate API calls across test files, lowers the risk of rate limiting, and provides a consistent test environment. Test files that are not yet migrated to the new pattern are parked in tmp/ until they are updated.

Global setup and teardown

New tests/BeforeAll.ps1 and tests/AfterAll.ps1 scripts handle shared test infrastructure:

  • BeforeAll.ps1 — Iterates all authentication scenarios, connects, cleans up stale repositories from previous runs, and creates a fresh test repository per auth/OS combination using the run ID (Test-{OS}-{TokenType}-{RunID}).
  • AfterAll.ps1 — Connects again per auth scenario and removes all repositories matching the test prefix, ensuring no orphaned resources remain.

Migrated test file

tests/Environments.Tests.ps1 has been updated to consume the shared repository instead of creating its own:

  • Removed per-context repository creation and cleanup.
  • Uses Get-GitHubRepository to reference the pre-created repo.
  • Switched from GUID-based naming to run-ID-based naming for consistency.

Parked (unmigrated) test files

The following test files have been moved to tmp/ and will be migrated in follow-up work:

  • Apps, Artifacts, Emojis, Enterprise, GitHub, GitHubFormatter, Organizations, Permissions, Releases, Repositories, Secrets, Teams, Users, Variables

Minor cleanup was applied to Emojis.Tests.ps1, Enterprise.Tests.ps1, and Users.Tests.ps1 (moved Connect-GitHubApp into BeforeAll, removed stale comment blocks).

Copilot AI and others added 4 commits January 5, 2026 23:04
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Copilot AI changed the title [WIP] Consolidate test setup and teardown tasks Add BeforeAll/AfterAll scripts for centralized test resource cleanup Jan 5, 2026
- 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.
- 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.
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title Add BeforeAll/AfterAll scripts for centralized test resource cleanup Fix: skip repo linting on merge to main Jan 17, 2026
@github-actions
Copy link
Contributor

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Path Description
src/** Module source code
README.md Documentation

Build, test, and publish stages will be skipped for this PR.

If you believe this is incorrect, please verify that your changes are in the correct locations.

@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title Fix: skip repo linting on merge to main 🩹 [Patch]: Consolidate test setup/teardown tasks Feb 15, 2026
@github-actions
Copy link
Contributor

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Path Description
src/** Module source code
README.md Documentation

Build, test, and publish stages will be skipped for this PR.

If you believe this is incorrect, please verify that your changes are in the correct locations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

🩹 [Patch]: Consolidate test setup/teardown tasks

2 participants