Skip to content

Improve pkg/workflow/compiler_test.go quality with clearer assertions and missing edge-case coverage#33897

Merged
pelikhan merged 3 commits into
mainfrom
copilot/testify-expert-improve-test-quality-another-one
May 22, 2026
Merged

Improve pkg/workflow/compiler_test.go quality with clearer assertions and missing edge-case coverage#33897
pelikhan merged 3 commits into
mainfrom
copilot/testify-expert-improve-test-quality-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

This issue targeted incremental test-quality improvements in pkg/workflow/compiler_test.go: better assertion diagnostics, less manual error reporting, and explicit edge-case coverage for template-injection validation and HEAD lockfile reads.
This PR focuses on those gaps without changing production behavior.

  • Assertion quality and diagnostics

    • Added descriptive messages to previously bare require.NoError(t, err) calls in compiler_test.go.
    • Kept setup-vs-validation assertion intent aligned with existing testify patterns.
  • Manual error reporting → testify assertions

    • Replaced manual t.Errorf failure reporting in concurrent compilation checks with structured testify assertions for clearer, single-point failures.
    • Simplified failure output to be easier to scan in CI logs.
  • Template-injection fallback edge case

    • Added TestValidateTemplateInjection_IgnoresMalformedYAMLInFallback to cover the parsedWorkflow == nil path when YAML reparsing fails.
    • Verifies malformed YAML in fallback scanning does not incorrectly raise a template-injection error.
  • readLockFileFromHEAD git-state coverage

    • Added TestReadLockFileFromHEAD_GitStates with subtests for:
      • missing gitRoot
      • reading committed HEAD content when working tree differs
      • file absent from HEAD
    • Included local git repo setup helper in test scope to keep scenarios explicit and deterministic.
t.Run("returns committed content from HEAD", func(t *testing.T) {
    repoDir := testutil.TempDir(t, "read-head")
    runGitCommand(t, repoDir, "init")
    runGitCommand(t, repoDir, "config", "user.email", "test@example.com")
    runGitCommand(t, repoDir, "config", "user.name", "Test User")

    lockFile := filepath.Join(repoDir, "workflow.lock.yml")
    committedContent := "name: committed\n"
    require.NoError(t, os.WriteFile(lockFile, []byte(committedContent), 0644))
    runGitCommand(t, repoDir, "add", "workflow.lock.yml")
    runGitCommand(t, repoDir, "commit", "-m", "add lock file")

    require.NoError(t, os.WriteFile(lockFile, []byte("name: modified\n"), 0644))

    compiler := NewCompiler()
    compiler.gitRoot = repoDir

    content, err := compiler.readLockFileFromHEAD(lockFile)
    require.NoError(t, err)
    assert.Equal(t, committedContent, content)
})

Copilot AI and others added 2 commits May 22, 2026 00:13
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve test quality for pkg/workflow/compiler_test.go Improve pkg/workflow/compiler_test.go quality with clearer assertions and missing edge-case coverage May 22, 2026
Copilot AI requested a review from gh-aw-bot May 22, 2026 00:27
@github-actions
Copy link
Copy Markdown
Contributor

Hey @app/copilot-swe-agent 👋 — thanks for working on test quality improvements! The technical content here looks solid, but this PR doesn't follow the contribution process for this repository.

Issue with the process:

  • Missing issue discussion — This project requires that non-core contributors create detailed agentic plans in issues first, discuss with the team, and then a core team member implements the PR. Direct PRs from bots or external contributors are not enabled per the CONTRIBUTING.md.

If this work was meant to address a specific quality gap, consider:

  1. Opening an issue describing the test quality improvements needed
  2. Discussing the approach with the core team
  3. Letting a core team member implement the changes through their agentic workflow

If you're a core team member using this bot, please link the issue this PR addresses or clarify the workflow context.

Close this PR and create a new issue in github/gh-aw titled:
"Test Quality: Improve pkg/workflow/compiler_test.go assertions and edge-case coverage"

In the issue body, include:
1. **Problem**: Current test assertions lack descriptive messages and miss edge cases (malformed YAML in fallback, git HEAD reads).
2. **Proposed changes**:
   - Add descriptive messages to bare require.NoError calls
   - Convert manual t.Errorf to testify assertions
   - Add TestValidateTemplateInjection_IgnoresMalformedYAMLInFallback
   - Add TestReadLockFileFromHEAD_GitStates with subtests for missing git root, HEAD content reading, and absent files
3. **Expected outcome**: Better test diagnostics and complete edge-case coverage in compiler_test.go
4. **Implementation notes**: All changes are test-only, no production code impact.

Label the issue with "test-quality" and "good-first-agentic-plan" if applicable.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • patchdiff.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "patchdiff.githubusercontent.com"

See Network Configuration for more information.

Generated by ✅ Contribution Check · ● 2.6M ·

@pelikhan pelikhan marked this pull request as ready for review May 22, 2026 01:39
Copilot AI review requested due to automatic review settings May 22, 2026 01:39
@pelikhan pelikhan merged commit eb48eb0 into main May 22, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/testify-expert-improve-test-quality-another-one branch May 22, 2026 01:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves unit test quality and coverage in pkg/workflow/compiler_test.go by adding clearer assertion messages, replacing manual error reporting with structured testify assertions, and introducing explicit regression tests for template-injection validation fallback behavior and readLockFileFromHEAD across common git states.

Changes:

  • Added descriptive context strings to multiple require.NoError / require.NoErrorf assertions for better CI diagnostics.
  • Simplified concurrent/performance test failure reporting via assert.Empty and require.LessOrEqual.
  • Added new tests covering: malformed-YAML handling in template-injection fallback scanning, and readLockFileFromHEAD behavior for missing git root / committed-vs-working-tree content / absent file in HEAD.
Show a summary per file
File Description
pkg/workflow/compiler_test.go Improves assertion diagnostics and adds targeted edge-case tests for template-injection fallback and HEAD lockfile reads.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[testify-expert] Improve Test Quality: pkg/workflow/compiler_test.go

4 participants