TestEnsureCopilotSetupSteps_ReleaseMode tests that release mode uses the actions/setup-cli action
(t *testing.T)
| 434 | |
| 435 | // TestEnsureCopilotSetupSteps_ReleaseMode tests that release mode uses the actions/setup-cli action |
| 436 | func TestEnsureCopilotSetupSteps_ReleaseMode(t *testing.T) { |
| 437 | // Create temporary directory |
| 438 | tmpDir := t.TempDir() |
| 439 | |
| 440 | // Change to temp directory |
| 441 | originalDir, err := os.Getwd() |
| 442 | if err != nil { |
| 443 | t.Fatalf("Failed to get current directory: %v", err) |
| 444 | } |
| 445 | defer func() { |
| 446 | _ = os.Chdir(originalDir) |
| 447 | }() |
| 448 | |
| 449 | if err := os.Chdir(tmpDir); err != nil { |
| 450 | t.Fatalf("Failed to change to temp directory: %v", err) |
| 451 | } |
| 452 | |
| 453 | // Call function with release mode |
| 454 | testVersion := "v1.2.3" |
| 455 | err = ensureCopilotSetupSteps(context.Background(), false, workflow.ActionModeRelease, testVersion) |
| 456 | if err != nil { |
| 457 | t.Fatalf("ensureCopilotSetupSteps(context.Background()) failed: %v", err) |
| 458 | } |
| 459 | |
| 460 | // Read generated file |
| 461 | setupStepsPath := filepath.Join(".github", "workflows", "copilot-setup-steps.yml") |
| 462 | content, err := os.ReadFile(setupStepsPath) |
| 463 | if err != nil { |
| 464 | t.Fatalf("Failed to read copilot-setup-steps.yml: %v", err) |
| 465 | } |
| 466 | |
| 467 | contentStr := string(content) |
| 468 | |
| 469 | // Verify it uses actions/setup-cli with the correct version tag |
| 470 | if !strings.Contains(contentStr, "actions/setup-cli@v1.2.3") { |
| 471 | t.Errorf("Expected copilot-setup-steps.yml to use actions/setup-cli@v1.2.3 in release mode, got:\n%s", contentStr) |
| 472 | } |
| 473 | |
| 474 | // Verify it uses the correct version in the with parameter |
| 475 | if !strings.Contains(contentStr, "version: v1.2.3") { |
| 476 | t.Errorf("Expected copilot-setup-steps.yml to have version: v1.2.3, got:\n%s", contentStr) |
| 477 | } |
| 478 | |
| 479 | // Verify it has checkout step |
| 480 | if !strings.Contains(contentStr, "actions/checkout@v6") { |
| 481 | t.Error("Expected copilot-setup-steps.yml to have checkout step in release mode") |
| 482 | } |
| 483 | |
| 484 | // Verify it doesn't use curl/install-gh-aw.sh |
| 485 | if strings.Contains(contentStr, "install-gh-aw.sh") || strings.Contains(contentStr, "curl -fsSL") { |
| 486 | t.Error("Expected copilot-setup-steps.yml to NOT use curl method in release mode") |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | // TestEnsureCopilotSetupSteps_DevMode tests that dev mode uses curl install method |
| 491 | func TestEnsureCopilotSetupSteps_DevMode(t *testing.T) { |
nothing calls this directly
no test coverage detected