(t *testing.T)
| 755 | } |
| 756 | |
| 757 | func TestFixCommand_GrepToolRemoval(t *testing.T) { |
| 758 | // Create a temporary directory for test files |
| 759 | tmpDir := t.TempDir() |
| 760 | workflowFile := filepath.Join(tmpDir, "test-workflow.md") |
| 761 | |
| 762 | // Create a workflow with deprecated tools.grep field |
| 763 | content := `--- |
| 764 | on: |
| 765 | workflow_dispatch: |
| 766 | |
| 767 | tools: |
| 768 | bash: ["echo", "ls"] |
| 769 | grep: true |
| 770 | github: |
| 771 | |
| 772 | permissions: |
| 773 | contents: read |
| 774 | --- |
| 775 | |
| 776 | # Test Workflow |
| 777 | |
| 778 | This workflow uses the deprecated grep tool. |
| 779 | ` |
| 780 | |
| 781 | if err := os.WriteFile(workflowFile, []byte(content), 0644); err != nil { |
| 782 | t.Fatalf("Failed to create test file: %v", err) |
| 783 | } |
| 784 | |
| 785 | // Get the grep removal codemod |
| 786 | grepCodemod := getCodemodByID("grep-tool-removal") |
| 787 | if grepCodemod == nil { |
| 788 | t.Fatal("grep-tool-removal codemod not found") |
| 789 | } |
| 790 | |
| 791 | // Process the file |
| 792 | fixed, _, err := processWorkflowFileWithInfo(workflowFile, []Codemod{*grepCodemod}, true, false) |
| 793 | if err != nil { |
| 794 | t.Fatalf("Failed to process workflow file: %v", err) |
| 795 | } |
| 796 | |
| 797 | if !fixed { |
| 798 | t.Error("Expected file to be fixed, but no changes were made") |
| 799 | } |
| 800 | |
| 801 | // Read the updated content |
| 802 | updatedContent, err := os.ReadFile(workflowFile) |
| 803 | if err != nil { |
| 804 | t.Fatalf("Failed to read updated file: %v", err) |
| 805 | } |
| 806 | |
| 807 | updatedStr := string(updatedContent) |
| 808 | |
| 809 | // Verify the change - grep should be removed |
| 810 | if strings.Contains(updatedStr, "grep:") { |
| 811 | t.Errorf("Expected grep to be removed, but it still exists:\n%s", updatedStr) |
| 812 | } |
| 813 | |
| 814 | // Verify other tools are preserved |
nothing calls this directly
no test coverage detected