(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func 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 := `--- |
| 66 | on: |
| 67 | workflow_dispatch: |
| 68 | |
| 69 | timeout_minutes: 30 |
| 70 | |
| 71 | permissions: |
| 72 | contents: read |
| 73 | --- |
| 74 | |
| 75 | # Test Workflow |
| 76 | |
| 77 | This 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 | } |
nothing calls this directly
no test coverage detected