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

Function TestFetchLocalWorkflow

pkg/cli/remote_workflow_test.go:24–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22}
23
24func TestFetchLocalWorkflow(t *testing.T) {
25 tests := []struct {
26 name string
27 content string
28 expectError bool
29 }{
30 {
31 name: "valid workflow file",
32 content: `---
33name: Test Workflow
34on: workflow_dispatch
35---
36
37# Test Workflow
38
39This is a test.
40`,
41 expectError: false,
42 },
43 {
44 name: "empty file",
45 content: "",
46 expectError: false,
47 },
48 {
49 name: "minimal content",
50 content: "# Hello",
51 expectError: false,
52 },
53 }
54
55 for _, tt := range tests {
56 t.Run(tt.name, func(t *testing.T) {
57 // Create a temporary file
58 tempDir := t.TempDir()
59 tempFile := filepath.Join(tempDir, "test-workflow.md")
60 err := os.WriteFile(tempFile, []byte(tt.content), 0644)
61 require.NoError(t, err, "should create temp file")
62
63 spec := &WorkflowSpec{
64 WorkflowPath: tempFile,
65 WorkflowName: "test-workflow",
66 }
67
68 result, err := fetchLocalWorkflow(spec, false)
69
70 if tt.expectError {
71 assert.Error(t, err, "expected error")
72 } else {
73 require.NoError(t, err, "should not error")
74 assert.Equal(t, []byte(tt.content), result.Content, "content should match")
75 assert.True(t, result.IsLocal, "should be marked as local")
76 assert.Empty(t, result.CommitSHA, "local workflows should not have commit SHA")
77 assert.Equal(t, tempFile, result.SourcePath, "source path should match")
78 }
79 })
80 }
81}

Callers

nothing calls this directly

Calls 3

fetchLocalWorkflowFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected