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

Function TestFixCommand_TimeoutMinutesMigration

pkg/cli/fix_command_test.go:59–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestFixCommand_TimeoutMinutesMigration(t *testing.T) {
60 // Create a temporary directory for test files
61 tmpDir := t.TempDir()
62 workflowFile := filepath.Join(tmpDir, "test-workflow.md")
63
64 // Create a workflow with deprecated timeout_minutes field
65 content := `---
66on:
67 workflow_dispatch:
68
69timeout_minutes: 30
70
71permissions:
72 contents: read
73---
74
75# Test Workflow
76
77This is a test workflow.
78`
79
80 if err := os.WriteFile(workflowFile, []byte(content), 0644); err != nil {
81 t.Fatalf("Failed to create test file: %v", err)
82 }
83
84 // Get the timeout migration codemod
85 timeoutCodemod := getCodemodByID("timeout-minutes-migration")
86 if timeoutCodemod == nil {
87 t.Fatal("timeout-minutes-migration codemod not found")
88 }
89
90 // Process the file
91 fixed, _, err := processWorkflowFileWithInfo(workflowFile, []Codemod{*timeoutCodemod}, true, false)
92 if err != nil {
93 t.Fatalf("Failed to process workflow file: %v", err)
94 }
95
96 if !fixed {
97 t.Error("Expected file to be fixed, but no changes were made")
98 }
99
100 // Read the updated content
101 updatedContent, err := os.ReadFile(workflowFile)
102 if err != nil {
103 t.Fatalf("Failed to read updated file: %v", err)
104 }
105
106 updatedStr := string(updatedContent)
107
108 // Verify the change
109 if strings.Contains(updatedStr, "timeout_minutes:") {
110 t.Error("Expected timeout_minutes to be replaced, but it still exists")
111 }
112
113 if !strings.Contains(updatedStr, "timeout-minutes: 30") {
114 t.Errorf("Expected timeout-minutes: 30 in updated content, got:\n%s", updatedStr)
115 }
116}

Callers

nothing calls this directly

Calls 4

getCodemodByIDFunction · 0.85
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected