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

Function TestFixCommand_MCPScriptsModeRemoval

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

Source from the content-addressed store, hash-verified

621}
622
623func TestFixCommand_MCPScriptsModeRemoval(t *testing.T) {
624 // Create a temporary directory for test files
625 tmpDir := t.TempDir()
626 workflowFile := filepath.Join(tmpDir, "test-workflow.md")
627
628 // Create a workflow with deprecated mcp-scripts.mode field
629 content := `---
630on: workflow_dispatch
631engine: copilot
632mcp-scripts:
633 mode: http
634 test-tool:
635 description: Test tool
636 script: |
637 return { result: "test" };
638---
639
640# Test Workflow
641
642This is a test workflow with mcp-scripts mode field.
643`
644
645 if err := os.WriteFile(workflowFile, []byte(content), 0644); err != nil {
646 t.Fatalf("Failed to create test file: %v", err)
647 }
648
649 // Get the mcp-scripts mode removal codemod
650 modeCodemod := getCodemodByID("mcp-scripts-mode-removal")
651 if modeCodemod == nil {
652 t.Fatal("mcp-scripts-mode-removal codemod not found")
653 }
654
655 // Process the file
656 fixed, _, err := processWorkflowFileWithInfo(workflowFile, []Codemod{*modeCodemod}, true, false)
657 if err != nil {
658 t.Fatalf("Failed to process workflow file: %v", err)
659 }
660
661 if !fixed {
662 t.Error("Expected file to be fixed, but no changes were made")
663 }
664
665 // Read the updated content
666 updatedContent, err := os.ReadFile(workflowFile)
667 if err != nil {
668 t.Fatalf("Failed to read updated file: %v", err)
669 }
670
671 updatedStr := string(updatedContent)
672
673 t.Logf("Updated content:\n%s", updatedStr)
674
675 // Verify the change - mode field should be removed
676 if strings.Contains(updatedStr, "mode:") {
677 t.Errorf("Expected mode field to be removed, but it still exists:\n%s", updatedStr)
678 }
679
680 // Verify mcp-scripts block and test-tool are preserved

Callers

nothing calls this directly

Calls 4

getCodemodByIDFunction · 0.85
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected