🩹 [Patch]: Consolidate test setup/teardown tasks#541
Conversation
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>
- 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.
…in BeforeAll script
… in AfterAll script
ad98f64 to
3dbdfc3
Compare
…t/consolidate-test-setup-tasks
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
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. |
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
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. |
…t/consolidate-test-setup-tasks
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
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. |
Phase 1 fixes: - Environments.Tests.ps1: Add missing $testName variable - AfterAll.ps1: Fix 'setup' labels to 'teardown/cleanup', remove unused vars Phase 2 - Lightweight tests moved from tmp/ to tests/: - GitHubFormatter.Tests.ps1 (pure unit tests, no API calls) - Emojis.Tests.ps1 (read-only API) - Enterprise.Tests.ps1 (read-only, fix Describe 'Template' bug) - Permissions.Tests.ps1 (read-only validation) - Artifacts.Tests.ps1 (reads existing workflow artifacts) - GitHub.Tests.ps1 (read-only/config, no remote resources) - Apps.Tests.ps1 (uses existing app installations) - Users.Tests.ps1 (user-specific, can't be pre-shared) Phase 3 - Medium complexity: - Teams.Tests.ps1 (team creation not a rate-limit hotspot) Remaining in tmp/ for Phase 4 (heavy, need shared infra expansion): - Organizations.Tests.ps1 - Releases.Tests.ps1 - Repositories.Tests.ps1 - Secrets.Tests.ps1 - Variables.Tests.ps1
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
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. |
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
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. |
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 intmp/until they are updated.Global setup and teardown
New
tests/BeforeAll.ps1andtests/AfterAll.ps1scripts handle shared test infrastructure:Test-{OS}-{TokenType}-{RunID}).Migrated test file
tests/Environments.Tests.ps1has been updated to consume the shared repository instead of creating its own:Get-GitHubRepositoryto reference the pre-created repo.Parked (unmigrated) test files
The following test files have been moved to
tmp/and will be migrated in follow-up work:Minor cleanup was applied to
Emojis.Tests.ps1,Enterprise.Tests.ps1, andUsers.Tests.ps1(movedConnect-GitHubAppintoBeforeAll, removed stale comment blocks).