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

Function TestFixWithDirFlagAndSpecificWorkflow

pkg/cli/fix_dir_flag_test.go:70–133  ·  view source on GitHub ↗

TestFixWithDirFlagAndSpecificWorkflow tests --dir with specific workflow

(t *testing.T)

Source from the content-addressed store, hash-verified

68
69// TestFixWithDirFlagAndSpecificWorkflow tests --dir with specific workflow
70func TestFixWithDirFlagAndSpecificWorkflow(t *testing.T) {
71 // Create a temporary directory for test
72 tmpDir := t.TempDir()
73 customDir := filepath.Join(tmpDir, "custom-workflows")
74 if err := os.MkdirAll(customDir, 0755); err != nil {
75 t.Fatalf("Failed to create custom workflow directory: %v", err)
76 }
77
78 // Create two test workflows
79 workflow1Content := `---
80on: workflow_dispatch
81timeout_minutes: 30
82---
83# Workflow 1
84`
85 workflow1File := filepath.Join(customDir, "workflow1.md")
86 if err := os.WriteFile(workflow1File, []byte(workflow1Content), 0644); err != nil {
87 t.Fatalf("Failed to create workflow1 file: %v", err)
88 }
89
90 workflow2Content := `---
91on: workflow_dispatch
92timeout_minutes: 60
93---
94# Workflow 2
95`
96 workflow2File := filepath.Join(customDir, "workflow2.md")
97 if err := os.WriteFile(workflow2File, []byte(workflow2Content), 0644); err != nil {
98 t.Fatalf("Failed to create workflow2 file: %v", err)
99 }
100
101 // Run fix command on specific workflow with --dir flag
102 config := FixConfig{
103 WorkflowIDs: []string{workflow1File},
104 Write: true,
105 Verbose: false,
106 WorkflowDir: customDir,
107 }
108
109 err := RunFix(config)
110 if err != nil {
111 t.Fatalf("RunFix with --dir and specific workflow should succeed, got error: %v", err)
112 }
113
114 // Verify workflow1 was fixed
115 updated1Content, err := os.ReadFile(workflow1File)
116 if err != nil {
117 t.Fatalf("Failed to read updated workflow1 file: %v", err)
118 }
119
120 if !strings.Contains(string(updated1Content), "timeout-minutes: 30") {
121 t.Error("Expected workflow1 to be fixed")
122 }
123
124 // Verify workflow2 was NOT fixed (we didn't specify it)
125 updated2Content, err := os.ReadFile(workflow2File)
126 if err != nil {
127 t.Fatalf("Failed to read workflow2 file: %v", err)

Callers

nothing calls this directly

Calls 2

RunFixFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected