TestFetchDispatchWorkflows_SameSourceSkips verifies that an existing dispatch-workflow file from the SAME source repo is silently skipped without error.
(t *testing.T)
| 1628 | // TestFetchDispatchWorkflows_SameSourceSkips verifies that an existing dispatch-workflow |
| 1629 | // file from the SAME source repo is silently skipped without error. |
| 1630 | func TestFetchDispatchWorkflows_SameSourceSkips(t *testing.T) { |
| 1631 | dir := t.TempDir() |
| 1632 | workflowsDir := dir |
| 1633 | |
| 1634 | // Pre-existing file from the SAME source repo |
| 1635 | existingPath := filepath.Join(dir, "target-workflow.md") |
| 1636 | existingContent := `--- |
| 1637 | source: github/gh-aw/.github/workflows/target-workflow.md@v1 |
| 1638 | --- |
| 1639 | # Target workflow from the same repo |
| 1640 | ` |
| 1641 | require.NoError(t, os.WriteFile(existingPath, []byte(existingContent), 0644)) |
| 1642 | |
| 1643 | content := `--- |
| 1644 | safe-outputs: |
| 1645 | dispatch-workflow: |
| 1646 | workflows: |
| 1647 | - target-workflow |
| 1648 | --- |
| 1649 | # Main |
| 1650 | ` |
| 1651 | spec := &WorkflowSpec{ |
| 1652 | RepoSpec: RepoSpec{RepoSlug: "github/gh-aw", Version: "main"}, |
| 1653 | WorkflowPath: ".github/workflows/main.md", |
| 1654 | } |
| 1655 | |
| 1656 | err := fetchAndSaveRemoteDispatchWorkflows(context.Background(), content, spec, workflowsDir, false, false, nil) |
| 1657 | require.NoError(t, err, "should not error when existing file is from the same source repo") |
| 1658 | |
| 1659 | // File must not have been modified |
| 1660 | got, readErr := os.ReadFile(existingPath) |
| 1661 | require.NoError(t, readErr) |
| 1662 | assert.Equal(t, existingContent, string(got), "existing same-source file must be left unchanged") |
| 1663 | } |
| 1664 | |
| 1665 | // TestFetchDispatchWorkflows_NoSourceConflict verifies that a file with no source field |
| 1666 | // is treated as a conflict (unknown origin). |
nothing calls this directly
no test coverage detected