TestEnsureCopilotSetupSteps_DevMode tests that dev mode uses curl install method
(t *testing.T)
| 489 | |
| 490 | // TestEnsureCopilotSetupSteps_DevMode tests that dev mode uses curl install method |
| 491 | func TestEnsureCopilotSetupSteps_DevMode(t *testing.T) { |
| 492 | // Create temporary directory |
| 493 | tmpDir := t.TempDir() |
| 494 | |
| 495 | // Change to temp directory |
| 496 | originalDir, err := os.Getwd() |
| 497 | if err != nil { |
| 498 | t.Fatalf("Failed to get current directory: %v", err) |
| 499 | } |
| 500 | defer func() { |
| 501 | _ = os.Chdir(originalDir) |
| 502 | }() |
| 503 | |
| 504 | if err := os.Chdir(tmpDir); err != nil { |
| 505 | t.Fatalf("Failed to change to temp directory: %v", err) |
| 506 | } |
| 507 | |
| 508 | // Call function with dev mode |
| 509 | err = ensureCopilotSetupSteps(context.Background(), false, workflow.ActionModeDev, "dev") |
| 510 | if err != nil { |
| 511 | t.Fatalf("ensureCopilotSetupSteps(context.Background()) failed: %v", err) |
| 512 | } |
| 513 | |
| 514 | // Read generated file |
| 515 | setupStepsPath := filepath.Join(".github", "workflows", "copilot-setup-steps.yml") |
| 516 | content, err := os.ReadFile(setupStepsPath) |
| 517 | if err != nil { |
| 518 | t.Fatalf("Failed to read copilot-setup-steps.yml: %v", err) |
| 519 | } |
| 520 | |
| 521 | contentStr := string(content) |
| 522 | |
| 523 | // Verify it uses curl method |
| 524 | if !strings.Contains(contentStr, "install-gh-aw.sh") { |
| 525 | t.Error("Expected copilot-setup-steps.yml to use install-gh-aw.sh in dev mode") |
| 526 | } |
| 527 | |
| 528 | // Verify it doesn't use actions/setup-cli |
| 529 | if strings.Contains(contentStr, "actions/setup-cli") { |
| 530 | t.Error("Expected copilot-setup-steps.yml to NOT use actions/setup-cli in dev mode") |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | // TestEnsureCopilotSetupSteps_CreateWithReleaseMode tests creating a new file with release mode |
| 535 | func TestEnsureCopilotSetupSteps_CreateWithReleaseMode(t *testing.T) { |
nothing calls this directly
no test coverage detected