TestAddRemoteWorkflowWithVersion tests adding a remote workflow with a specific version tag Uses the 4+ part format with explicit path since the workflow is in .github/workflows/ This test requires GitHub authentication
(t *testing.T)
| 677 | // Uses the 4+ part format with explicit path since the workflow is in .github/workflows/ |
| 678 | // This test requires GitHub authentication |
| 679 | func TestAddRemoteWorkflowWithVersion(t *testing.T) { |
| 680 | // Skip if GitHub authentication is not available |
| 681 | authCmd := exec.Command("gh", "auth", "status") |
| 682 | if err := authCmd.Run(); err != nil { |
| 683 | t.Skip("Skipping test: GitHub authentication not available (gh auth status failed)") |
| 684 | } |
| 685 | |
| 686 | setup := setupAddIntegrationTest(t) |
| 687 | defer setup.cleanup() |
| 688 | |
| 689 | // Use a workflow spec with explicit path (owner/repo/path/workflow.md@version format) |
| 690 | // The 3-part format (owner/repo/workflow@version) looks in workflows/ directory, |
| 691 | // but this workflow is in .github/workflows/, so we need the explicit path |
| 692 | workflowSpec := "github/gh-aw/.github/workflows/github-mcp-tools-report.md@v0.45.5" |
| 693 | |
| 694 | cmd := exec.Command(setup.binaryPath, "add", workflowSpec, "--verbose") |
| 695 | cmd.Dir = setup.tempDir |
| 696 | output, err := cmd.CombinedOutput() |
| 697 | outputStr := string(output) |
| 698 | |
| 699 | t.Logf("Command output:\n%s", outputStr) |
| 700 | |
| 701 | require.NoError(t, err, "add command should succeed: %s", outputStr) |
| 702 | |
| 703 | // Verify the workflow file was created |
| 704 | workflowsDir := filepath.Join(setup.tempDir, ".github", "workflows") |
| 705 | workflowFile := filepath.Join(workflowsDir, "github-mcp-tools-report.md") |
| 706 | _, err = os.Stat(workflowFile) |
| 707 | require.NoError(t, err, "workflow file should exist: %s", workflowFile) |
| 708 | |
| 709 | // Read and verify source pinning |
| 710 | content, err := os.ReadFile(workflowFile) |
| 711 | require.NoError(t, err, "should be able to read workflow file") |
| 712 | contentStr := string(content) |
| 713 | |
| 714 | // Should have source with version pinning |
| 715 | assert.Contains(t, contentStr, "source:", "workflow should have source field") |
| 716 | // The source should reference the commit SHA (not the tag directly) |
| 717 | // This ensures reproducible builds |
| 718 | assert.True(t, |
| 719 | strings.Contains(contentStr, "@") && strings.Contains(contentStr, "github/gh-aw"), |
| 720 | "source should have commit pinning") |
| 721 | } |
| 722 | |
| 723 | // TestAddWorkflowWithEngineOverride tests that --engine flag adds/updates the engine field in the workflow |
| 724 | func TestAddWorkflowWithEngineOverride(t *testing.T) { |
nothing calls this directly
no test coverage detected