TestAddWorkflowWithEngineOverride tests that --engine flag adds/updates the engine field in the workflow
(t *testing.T)
| 722 | |
| 723 | // TestAddWorkflowWithEngineOverride tests that --engine flag adds/updates the engine field in the workflow |
| 724 | func TestAddWorkflowWithEngineOverride(t *testing.T) { |
| 725 | setup := setupAddIntegrationTest(t) |
| 726 | defer setup.cleanup() |
| 727 | |
| 728 | // Create a local workflow file WITHOUT an engine specified |
| 729 | sourceDir := filepath.Join(setup.tempDir, "source-workflows") |
| 730 | err := os.MkdirAll(sourceDir, 0755) |
| 731 | require.NoError(t, err, "should create source directory") |
| 732 | |
| 733 | localWorkflowPath := filepath.Join(sourceDir, "no-engine-workflow.md") |
| 734 | localWorkflowContent := `--- |
| 735 | name: Workflow Without Engine |
| 736 | on: workflow_dispatch |
| 737 | permissions: |
| 738 | contents: read |
| 739 | --- |
| 740 | |
| 741 | # Workflow Without Engine |
| 742 | |
| 743 | This workflow does not specify an engine in frontmatter. |
| 744 | |
| 745 | Please analyze the repository. |
| 746 | ` |
| 747 | err = os.WriteFile(localWorkflowPath, []byte(localWorkflowContent), 0644) |
| 748 | require.NoError(t, err, "should write local workflow file") |
| 749 | |
| 750 | // Add the workflow with --engine claude |
| 751 | cmd := exec.Command(setup.binaryPath, "add", localWorkflowPath, "--engine", "claude") |
| 752 | cmd.Dir = setup.tempDir |
| 753 | output, err := cmd.CombinedOutput() |
| 754 | outputStr := string(output) |
| 755 | |
| 756 | t.Logf("Command output:\n%s", outputStr) |
| 757 | |
| 758 | require.NoError(t, err, "add command should succeed: %s", outputStr) |
| 759 | |
| 760 | // Verify the workflow file was created |
| 761 | workflowsDir := filepath.Join(setup.tempDir, ".github", "workflows") |
| 762 | workflowFile := filepath.Join(workflowsDir, "no-engine-workflow.md") |
| 763 | _, err = os.Stat(workflowFile) |
| 764 | require.NoError(t, err, "workflow file should exist: %s", workflowFile) |
| 765 | |
| 766 | // Read and verify the engine field was added |
| 767 | content, err := os.ReadFile(workflowFile) |
| 768 | require.NoError(t, err, "should be able to read workflow file") |
| 769 | contentStr := string(content) |
| 770 | |
| 771 | // Should have engine: claude in frontmatter |
| 772 | assert.Contains(t, contentStr, "engine: claude", "workflow should have engine field added") |
| 773 | } |
| 774 | |
| 775 | // TestAddWorkflowEngineOverrideReplacesExisting tests that --engine flag replaces existing engine |
| 776 | func TestAddWorkflowEngineOverrideReplacesExisting(t *testing.T) { |
nothing calls this directly
no test coverage detected