Improve test quality for activation checkout tests with testify#52698
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
PR Triage\n\n- Category: test\n- Risk: low\n- Priority: medium\n- Score: 42/100 (impact 25 + urgency 10 + quality 7)\n- Recommended action:
|
There was a problem hiding this comment.
Pull request overview
Improves activation checkout test quality and coverage.
Changes:
- Adopts Testify assertions and shared job extraction.
- Adds helper-function unit tests.
- Relocates and expands activation checkout tests.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/compiler_test_helpers_test.go |
Tests shared job extraction. |
pkg/workflow/compiler_activation_job_test.go |
Adds activation helper tests. |
pkg/workflow/compiler_activation_checkout_test.go |
Relocates and expands checkout tests. |
pkg/workflow/activation_checkout_test.go |
Removes the previous file after relocation. |
Review details
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Balanced
| // Verify it does NOT checkout .github/workflows for timestamp checking | ||
| assert.NotContains(t, activationJobSection, "Checkout workflows", "Should not have 'Checkout workflows' step - uses GitHub API for timestamp checking") |
There was a problem hiding this comment.
Addressed in 66172ca: the subtest now asserts the sparse checkout step (name: Checkout .github and .agents folders, sparse-checkout: |, sparse-checkout-cone-mode: true) and explicitly asserts the activation job does not contain name: Checkout repository.
| t.Run("empty input defaults to all comment events", func(t *testing.T) { | ||
| result := buildCentralizedCommandOnSection(nil) | ||
| assert.NotEmpty(t, result) | ||
| assert.True(t, strings.HasPrefix(result, "on:\n")) | ||
| }) |
There was a problem hiding this comment.
Addressed in 66172ca: the default case now compares the complete expected on: section (issues, issue_comment, pull_request, pull_request_review_comment, discussion, discussion_comment), so a dropped event or a missing pull_request_comment → issue_comment dedup will fail the test.
|
@copilot Branch refresh has been requested for this PR via the update-branch action. Please finish a maintainer-ready pass by running the
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
PR Triage
Automated triage by PR Triage Agent.
|
|
@copilot Please run the Open review feedback to resolve:
|
Actions taken: re-validated the merged branch locally; no file changes were needed, so nothing new was pushed. Hand-off: a maintainer needs to approve the pending Still needed: review approval from |
pkg/workflow/activation_checkout_test.goused rawif ... t.Error/t.Fatalchecks, duplicated brittle job-boundary parsing logic, and left several pure helper functions incompiler_activation_job.gountested.Testify adoption
require/assertthroughout the checkout test.File co-location
activation_checkout_test.go→compiler_activation_checkout_test.goto sit alongsidecompiler_activation_job.go.Job-boundary parsing
extractJobSectionhelper (already used across ~30 other test files but not here).TestExtractJobSectioncovering job-at-end-of-file, job-followed-by-another-job, nested multi-level indentation, and missing-job cases.New positive checkout case
contents: writepermissions are unconditionally rejected byvalidateDangerousPermissions, so a literal "workflow with contents: write" case isn't compilable. Instead, added a subtest usingsafe-outputs.create-pull-request(which requirescontents: writein its own downstream job) to verify the activation job still performs only the sparse.github/.agentscheckout, never a full-repo checkout, even when write-capable safe-outputs are configured.New unit tests (no
integrationbuild tag)activationEventSet— string/list/mapon:forms, metadata-field filtering (reaction,stop-after, etc.), invalid YAML, and unsupported types.buildCentralizedCommandOnSection— single event,pull_request_comment/issue_commentdedup, unknown identifiers, default (all events) behavior.injectIfConditionAfterNamealready had coverage incompiler_activation_job_test.go.)