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

Function TestFixCommand_GrepToolRemoval

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

Source from the content-addressed store, hash-verified

755}
756
757func 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 := `---
764on:
765 workflow_dispatch:
766
767tools:
768 bash: ["echo", "ls"]
769 grep: true
770 github:
771
772permissions:
773 contents: read
774---
775
776# Test Workflow
777
778This 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

Callers

nothing calls this directly

Calls 4

getCodemodByIDFunction · 0.85
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected