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

Function TestUpgradeCopilotSetupSteps_NoFile

pkg/cli/copilot_setup_test.go:960–989  ·  view source on GitHub ↗

TestUpgradeCopilotSetupSteps_NoFile tests upgrading when file doesn't exist

(t *testing.T)

Source from the content-addressed store, hash-verified

958
959// TestUpgradeCopilotSetupSteps_NoFile tests upgrading when file doesn't exist
960func 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
992func TestUpgradeCopilotSetupSteps_DevMode(t *testing.T) {

Callers

nothing calls this directly

Calls 3

upgradeCopilotSetupStepsFunction · 0.85
BackgroundMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected