Repository navigation
[testify-expert] Improve Test Quality: pkg/workflow/container_services_test.go #69967
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Current State
- File:
pkg/workflow/container_services_test.go(401 LOC, build tagintegration) - Source pair: none (exercises
ParseWorkflowFile/generateYAML; related:compiler_custom_job_properties.go,frontmatter_normalization.go) - Tests: 3 (
TestContainerSupport,TestServicesSupport,TestContainerAndServicesIndentation); ~9 table cases; 29t.Errorf/t.Fatalfcalls; 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: ...}infrontmatter_normalization.go; assert the normalizedworkflowData.Containerform explicitly. - Invalid inputs:
container: 123, container object withoutimage,servicesthat is not a map. Assert compile error. - Secrets in
credentialsmust 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
TestContainerAndServicesIndentationhas 9 repeatedstrings.Containschecks; 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
TestContainerSupportandTestServicesSupport) with a helper that parses the YAML (yaml.Unmarshal) and asserts onjobs[agent].container/.servicesstructurally.
4. Organization / readability
- Extract a
compileWorkflow(t, frontmatter)helper to remove the duplicated temp-dir/write/parse/generate boilerplate. - Use
t.TempDir()instead ofos.MkdirTemp+defer RemoveAll. - Use
t.Parallel()in subtests since each uses an isolated dir. - Use
assert.Empty/assert.Containsfor the Container field checks.
Acceptance Checklist
- All
t.Errorf/t.Fatalfreplaced with testifyassert/require - Shared compile helper and
t.TempDir()used - Agent-job section checks use parsed YAML
- New negative/edge cases added
-
make test-unitpasses (andgo 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
Reactions are currently unavailable
Activity
github-actions commentedon Oct 18, 2026
🍪 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! 🍪
github-actions commentedon Oct 19, 2026
🍪 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! 🍪
github-actions commentedon Oct 19, 2026
🍪 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! 🍪
github-actions commentedon Oct 20, 2026
This issue was automatically closed because it expired on 2026-10-20T18:02:12.367Z.