TestUpgradeCopilotSetupSteps_NoFile tests upgrading when file doesn't exist
(t *testing.T)
| 958 | |
| 959 | // TestUpgradeCopilotSetupSteps_NoFile tests upgrading when file doesn't exist |
| 960 | func TestUpgradeCopilotSetupSteps_NoFile(t *testing.T) { |
| 961 | tmpDir := t.TempDir() |
| 962 | originalDir, err := os.Getwd() |
| 963 | if err != nil { |
| 964 | t.Fatalf("Failed to get current directory: %v", err) |
| 965 | } |
| 966 | defer func() { _ = os.Chdir(originalDir) }() |
| 967 | |
| 968 | if err := os.Chdir(tmpDir); err != nil { |
| 969 | t.Fatalf("Failed to change to temp directory: %v", err) |
| 970 | } |
| 971 | |
| 972 | // Attempt to upgrade when file doesn't exist - should create new file |
| 973 | err = upgradeCopilotSetupSteps(context.Background(), false, workflow.ActionModeRelease, "v2.0.0") |
| 974 | if err != nil { |
| 975 | t.Fatalf("upgradeCopilotSetupSteps(context.Background()) failed: %v", err) |
| 976 | } |
| 977 | |
| 978 | // Verify file was created with the new version |
| 979 | setupStepsPath := filepath.Join(".github", "workflows", "copilot-setup-steps.yml") |
| 980 | content, err := os.ReadFile(setupStepsPath) |
| 981 | if err != nil { |
| 982 | t.Fatalf("Failed to read created file: %v", err) |
| 983 | } |
| 984 | |
| 985 | contentStr := string(content) |
| 986 | if !strings.Contains(contentStr, "actions/setup-cli@v2.0.0") { |
| 987 | t.Errorf("Expected new file to have @v2.0.0, got:\n%s", contentStr) |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | // TestUpgradeCopilotSetupSteps_DevMode tests that dev mode doesn't use actions/setup-cli |
| 992 | func TestUpgradeCopilotSetupSteps_DevMode(t *testing.T) { |
nothing calls this directly
no test coverage detected