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

Function TestFixWithDirFlag

pkg/cli/fix_dir_flag_test.go:13–67  ·  view source on GitHub ↗

TestFixWithDirFlag tests the --dir flag functionality

(t *testing.T)

Source from the content-addressed store, hash-verified

11
12// TestFixWithDirFlag tests the --dir flag functionality
13func TestFixWithDirFlag(t *testing.T) {
14 // Create a temporary directory for test
15 tmpDir := t.TempDir()
16 customDir := filepath.Join(tmpDir, "custom-workflows")
17 if err := os.MkdirAll(customDir, 0755); err != nil {
18 t.Fatalf("Failed to create custom workflow directory: %v", err)
19 }
20
21 // Create a test workflow with deprecated field
22 workflowContent := `---
23on:
24 workflow_dispatch:
25
26timeout_minutes: 30
27
28permissions:
29 contents: read
30---
31
32# Test Workflow
33
34This is a test workflow with deprecated timeout_minutes field.
35`
36 workflowFile := filepath.Join(customDir, "test.md")
37 if err := os.WriteFile(workflowFile, []byte(workflowContent), 0644); err != nil {
38 t.Fatalf("Failed to create test workflow file: %v", err)
39 }
40
41 // Run fix command with --dir flag
42 config := FixConfig{
43 WorkflowIDs: []string{},
44 Write: true,
45 Verbose: false,
46 WorkflowDir: customDir,
47 }
48
49 err := RunFix(config)
50 if err != nil {
51 t.Fatalf("RunFix with --dir should succeed, got error: %v", err)
52 }
53
54 // Verify the file was fixed
55 updatedContent, err := os.ReadFile(workflowFile)
56 if err != nil {
57 t.Fatalf("Failed to read updated file: %v", err)
58 }
59
60 updatedStr := string(updatedContent)
61 if strings.Contains(updatedStr, "timeout_minutes:") {
62 t.Error("Expected timeout_minutes to be replaced")
63 }
64 if !strings.Contains(updatedStr, "timeout-minutes: 30") {
65 t.Errorf("Expected timeout-minutes: 30 in updated content, got:\n%s", updatedStr)
66 }
67}
68
69// TestFixWithDirFlagAndSpecificWorkflow tests --dir with specific workflow
70func TestFixWithDirFlagAndSpecificWorkflow(t *testing.T) {

Callers

nothing calls this directly

Calls 3

RunFixFunction · 0.85
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected