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

Function TestLoadWorkflowMCPConfigs

pkg/cli/mcp_workflow_loader_test.go:16–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestLoadWorkflowMCPConfigs(t *testing.T) {
17 // Create a temporary directory for test workflows
18 tmpDir := testutil.TempDir(t, "test-*")
19 workflowsDir := filepath.Join(tmpDir, constants.GetWorkflowDir())
20 err := os.MkdirAll(workflowsDir, 0755)
21 if err != nil {
22 t.Fatalf("Failed to create test directory: %v", err)
23 }
24
25 // Create a test workflow with MCP servers
26 testWorkflowContent := `---
27on:
28 workflow_dispatch:
29
30permissions: read-all
31
32safe-outputs:
33 create-issue:
34 title-prefix: "[Test] "
35
36tools:
37 github:
38 mcp:
39 type: stdio
40 command: "npx"
41 args: ["@github/github-mcp-server"]
42 allowed: ["create_issue"]
43
44mcp-servers:
45 test-server:
46 type: stdio
47 command: "node"
48 args: ["test-server.js"]
49 allowed: ["test_tool_1", "test_tool_2"]
50
51---
52
53# Test Workflow
54This is a test workflow.`
55
56 testWorkflowPath := filepath.Join(workflowsDir, "test-workflow.md")
57 err = os.WriteFile(testWorkflowPath, []byte(testWorkflowContent), 0644)
58 if err != nil {
59 t.Fatalf("Failed to create test workflow file: %v", err)
60 }
61
62 t.Run("load_workflow_with_no_filter", func(t *testing.T) {
63 workflowData, mcpConfigs, err := loadWorkflowMCPConfigs(testWorkflowPath, "")
64 if err != nil {
65 t.Errorf("loadWorkflowMCPConfigs() error = %v", err)
66 return
67 }
68
69 if workflowData == nil {
70 t.Error("Expected workflowData to be non-nil")
71 return
72 }
73

Callers

nothing calls this directly

Calls 6

TempDirFunction · 0.92
GetWorkflowDirFunction · 0.92
loadWorkflowMCPConfigsFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected