(t *testing.T)
| 109 | } |
| 110 | |
| 111 | func TestCopilotInstallerCustomVersion(t *testing.T) { |
| 112 | // Test that pinned version from engine config is ignored in favor of default pinned version |
| 113 | engine := NewCopilotEngine() |
| 114 | |
| 115 | customVersion := "1.0.0" |
| 116 | workflowData := &WorkflowData{ |
| 117 | Name: "test-workflow", |
| 118 | EngineConfig: &EngineConfig{ |
| 119 | Version: customVersion, |
| 120 | }, |
| 121 | } |
| 122 | if workflowData.EngineConfig.Version != customVersion { |
| 123 | t.Fatalf("Expected initial engine config version %q, got: %q", customVersion, workflowData.EngineConfig.Version) |
| 124 | } |
| 125 | |
| 126 | steps := engine.GetInstallationSteps(workflowData) |
| 127 | |
| 128 | if workflowData.EngineConfig.Version != string(constants.DefaultCopilotVersion) { |
| 129 | t.Fatalf("Expected engine config version to be normalized to default Copilot version %q, got: %q", constants.DefaultCopilotVersion, workflowData.EngineConfig.Version) |
| 130 | } |
| 131 | |
| 132 | // Find the install step |
| 133 | var installStep string |
| 134 | for _, step := range steps { |
| 135 | stepContent := strings.Join(step, "\n") |
| 136 | if strings.Contains(stepContent, "install_copilot_cli.sh") { |
| 137 | installStep = stepContent |
| 138 | break |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | if installStep == "" { |
| 143 | t.Fatal("Could not find install step with install_copilot_cli.sh") |
| 144 | } |
| 145 | |
| 146 | // Should contain default pinned version |
| 147 | if !strings.Contains(installStep, `install_copilot_cli.sh" `+string(constants.DefaultCopilotVersion)) { |
| 148 | t.Errorf("Expected default Copilot version in install step, got:\n%s", installStep) |
| 149 | } |
| 150 | if strings.Contains(installStep, `install_copilot_cli.sh" `+customVersion) { |
| 151 | t.Errorf("Expected pinned version to be ignored, got:\n%s", installStep) |
| 152 | } |
| 153 | |
| 154 | // Must pin GH_HOST: github.com to prevent workflow-level GHES overrides from |
| 155 | // leaking into the Copilot CLI install step. Without this pin, a workflow with |
| 156 | // env.GH_HOST set to a GHES host would cause the install/auth path to target |
| 157 | // the wrong host. |
| 158 | if !strings.Contains(installStep, "GH_HOST: github.com") { |
| 159 | t.Errorf("Install step should pin GH_HOST: github.com to prevent GHES workflow-level overrides, got:\n%s", installStep) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | func TestGenerateCopilotInstallerSteps_ExpressionVersion(t *testing.T) { |
| 164 | tests := []struct { |
nothing calls this directly
no test coverage detected