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

Function TestAddWorkflowWithEngineOverride

pkg/cli/add_integration_test.go:724–773  ·  view source on GitHub ↗

TestAddWorkflowWithEngineOverride tests that --engine flag adds/updates the engine field in the workflow

(t *testing.T)

Source from the content-addressed store, hash-verified

722
723// TestAddWorkflowWithEngineOverride tests that --engine flag adds/updates the engine field in the workflow
724func 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 := `---
735name: Workflow Without Engine
736on: workflow_dispatch
737permissions:
738 contents: read
739---
740
741# Workflow Without Engine
742
743This workflow does not specify an engine in frontmatter.
744
745Please 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
776func TestAddWorkflowEngineOverrideReplacesExisting(t *testing.T) {

Callers

nothing calls this directly

Calls 1

setupAddIntegrationTestFunction · 0.85

Tested by

no test coverage detected