TestUpgradeCopilotSetupSteps_DevMode tests that dev mode doesn't use actions/setup-cli
(t *testing.T)
| 990 | |
| 991 | // TestUpgradeCopilotSetupSteps_DevMode tests that dev mode doesn't use actions/setup-cli |
| 992 | func TestUpgradeCopilotSetupSteps_DevMode(t *testing.T) { |
| 993 | tmpDir := t.TempDir() |
| 994 | originalDir, err := os.Getwd() |
| 995 | if err != nil { |
| 996 | t.Fatalf("Failed to get current directory: %v", err) |
| 997 | } |
| 998 | defer func() { _ = os.Chdir(originalDir) }() |
| 999 | |
| 1000 | if err := os.Chdir(tmpDir); err != nil { |
| 1001 | t.Fatalf("Failed to change to temp directory: %v", err) |
| 1002 | } |
| 1003 | |
| 1004 | // Create .github/workflows directory |
| 1005 | workflowsDir := filepath.Join(".github", "workflows") |
| 1006 | if err := os.MkdirAll(workflowsDir, 0755); err != nil { |
| 1007 | t.Fatalf("Failed to create workflows directory: %v", err) |
| 1008 | } |
| 1009 | |
| 1010 | // Write existing workflow with curl install (dev mode) |
| 1011 | existingContent := `name: "Copilot Setup Steps" |
| 1012 | on: workflow_dispatch |
| 1013 | jobs: |
| 1014 | copilot-setup-steps: |
| 1015 | runs-on: ubuntu-latest |
| 1016 | steps: |
| 1017 | - name: Install gh-aw extension |
| 1018 | run: curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash |
| 1019 | - name: Verify gh-aw installation |
| 1020 | run: gh aw version |
| 1021 | ` |
| 1022 | setupStepsPath := filepath.Join(workflowsDir, "copilot-setup-steps.yml") |
| 1023 | if err := os.WriteFile(setupStepsPath, []byte(existingContent), 0644); err != nil { |
| 1024 | t.Fatalf("Failed to write existing workflow: %v", err) |
| 1025 | } |
| 1026 | |
| 1027 | // Attempt upgrade in dev mode - should not modify file |
| 1028 | err = upgradeCopilotSetupSteps(context.Background(), false, workflow.ActionModeDev, "dev") |
| 1029 | if err != nil { |
| 1030 | t.Fatalf("upgradeCopilotSetupSteps(context.Background()) failed: %v", err) |
| 1031 | } |
| 1032 | |
| 1033 | // Verify file was not changed (dev mode doesn't upgrade curl-based installs) |
| 1034 | content, err := os.ReadFile(setupStepsPath) |
| 1035 | if err != nil { |
| 1036 | t.Fatalf("Failed to read file: %v", err) |
| 1037 | } |
| 1038 | |
| 1039 | if string(content) != existingContent { |
| 1040 | t.Errorf("File should remain unchanged in dev mode") |
| 1041 | } |
| 1042 | } |
| 1043 | |
| 1044 | // TestUpgradeSetupCliVersionInContent tests the regex-based content upgrade helper. |
| 1045 | func TestUpgradeSetupCliVersionInContent(t *testing.T) { |
nothing calls this directly
no test coverage detected