MCPcopy Create free account
hub / github.com/github/gh-aw / TestFetchDispatchWorkflows_NoSourceConflict

Function TestFetchDispatchWorkflows_NoSourceConflict

pkg/cli/remote_workflow_test.go:1667–1692  ·  view source on GitHub ↗

TestFetchDispatchWorkflows_NoSourceConflict verifies that a file with no source field is treated as a conflict (unknown origin).

(t *testing.T)

Source from the content-addressed store, hash-verified

1665// TestFetchDispatchWorkflows_NoSourceConflict verifies that a file with no source field
1666// is treated as a conflict (unknown origin).
1667func TestFetchDispatchWorkflows_NoSourceConflict(t *testing.T) {
1668 dir := t.TempDir()
1669 workflowsDir := dir
1670
1671 // Pre-existing file with NO source field
1672 existingPath := filepath.Join(dir, "target-workflow.md")
1673 require.NoError(t, os.WriteFile(existingPath, []byte("# No source field\n"), 0644))
1674
1675 content := `---
1676safe-outputs:
1677 dispatch-workflow:
1678 workflows:
1679 - target-workflow
1680---
1681# Main
1682`
1683 spec := &WorkflowSpec{
1684 RepoSpec: RepoSpec{RepoSlug: "github/gh-aw", Version: "main"},
1685 WorkflowPath: ".github/workflows/main.md",
1686 }
1687
1688 err := fetchAndSaveRemoteDispatchWorkflows(context.Background(), content, spec, workflowsDir, false, false, nil)
1689 require.Error(t, err, "should error when existing file has no source field")
1690 assert.Contains(t, err.Error(), "target-workflow", "error should name the conflicting file")
1691 assert.Contains(t, err.Error(), "(no source field)", "error should show placeholder for missing source")
1692}
1693
1694// TestFetchDispatchWorkflows_ForceOverwritesConflict verifies that --force bypasses conflict detection.
1695func TestFetchDispatchWorkflows_ForceOverwritesConflict(t *testing.T) {

Callers

nothing calls this directly

Calls 3

BackgroundMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected