Skip to content

[testify-expert] Improve Test Quality: pkg/workflow/container_services_test.go #69967

Closed as not planned

Description

@github-actions

Current State

  • File: pkg/workflow/container_services_test.go (401 LOC, build tag integration)
  • Source pair: none (exercises ParseWorkflowFile / generateYAML; related: compiler_custom_job_properties.go, frontmatter_normalization.go)
  • Tests: 3 (TestContainerSupport, TestServicesSupport, TestContainerAndServicesIndentation); ~9 table cases; 29 t.Errorf/t.Fatalf calls; 0 testify assertions.

Strengths

  • Table-driven for container and services cases.
  • Covers string, object, and credentials container forms, plus indentation.

Prioritized Improvements

1. Missing / high-value tests

  • Container string shorthand is normalized to {image: ...} in frontmatter_normalization.go; assert the normalized workflowData.Container form explicitly.
  • Invalid inputs: container: 123, container object without image, services that is not a map. Assert compile error.
  • Secrets in credentials must stay as ${{ secrets.* }} expressions in the output.
  • Container/services must land only in the agent job, not in other jobs such as activation or detection.

2. Testify assertion upgrades

Replace all manual t.Errorf/t.Fatalf with require (setup, errors) and assert (checks).

Before / after
// before
tmpDir, err := os.MkdirTemp("", "workflow-container-test")
if err != nil { t.Fatalf("Failed to create temp dir: %v", err) }
defer os.RemoveAll(tmpDir)
...
if !strings.Contains(yamlContent, "    container:") {
    t.Errorf("Expected 4-space indented container section, but got:\n%s", yamlContent)
}

// after
tmpDir := t.TempDir()
require.NoError(t, os.WriteFile(filepath.Join(tmpDir, "test.md"), []byte(tt.frontmatter), 0o644))
...
assert.Contains(t, yamlContent, "    container:", "container should be indented within the job")

3. Table-driven refactors

  • TestContainerAndServicesIndentation has 9 repeated strings.Contains checks; convert to a table of {desc, expected} run in a loop, or assert one multi-line block.
  • Replace the hand-rolled line scanner for the agent job (duplicated in TestContainerSupport and TestServicesSupport) with a helper that parses the YAML (yaml.Unmarshal) and asserts on jobs[agent].container / .services structurally.

4. Organization / readability

  • Extract a compileWorkflow(t, frontmatter) helper to remove the duplicated temp-dir/write/parse/generate boilerplate.
  • Use t.TempDir() instead of os.MkdirTemp + defer RemoveAll.
  • Use t.Parallel() in subtests since each uses an isolated dir.
  • Use assert.Empty / assert.Contains for the Container field checks.

Acceptance Checklist

  • All t.Errorf/t.Fatalf replaced with testify assert/require
  • Shared compile helper and t.TempDir() used
  • Agent-job section checks use parsed YAML
  • New negative/edge cases added
  • make test-unit passes (and go test -tags integration ./pkg/workflow -run 'Container|Services')

Generated by 🧪 Daily Testify Uber Super Expert · copilot · auto · 13.4 AIC · ⌖ 0.679 AIC · ⊞ 8.3K · ◷

  • expires on Oct 20, 2026, 10:02 AM UTC-08:00

Activity

  1. github-actions commented on Oct 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 18.2 AIC · ⌖ 8.44 AIC · ⊞ 12.7K · ◷

  2. github-actions commented on Oct 19, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 11.3 AIC · ⌖ 10.9 AIC · ⊞ 12.7K · ◷

  3. github-actions commented on Oct 19, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 13.1 AIC · ⌖ 8.12 AIC · ⊞ 12.9K · ◷

  4. github-actions commented on Oct 20, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-10-20T18:02:12.367Z.

    Closed by Workflow

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions