(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func 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 := `--- |
| 27 | on: |
| 28 | workflow_dispatch: |
| 29 | |
| 30 | permissions: read-all |
| 31 | |
| 32 | safe-outputs: |
| 33 | create-issue: |
| 34 | title-prefix: "[Test] " |
| 35 | |
| 36 | tools: |
| 37 | github: |
| 38 | mcp: |
| 39 | type: stdio |
| 40 | command: "npx" |
| 41 | args: ["@github/github-mcp-server"] |
| 42 | allowed: ["create_issue"] |
| 43 | |
| 44 | mcp-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 |
| 54 | This 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 |
nothing calls this directly
no test coverage detected