(t *testing.T)
| 1167 | } |
| 1168 | |
| 1169 | func TestCodexEngineWithExpressionVersion(t *testing.T) { |
| 1170 | engine := NewCodexEngine() |
| 1171 | |
| 1172 | expressionVersion := "${{ inputs.engine-version }}" |
| 1173 | workflowData := &WorkflowData{ |
| 1174 | Name: "test-workflow", |
| 1175 | EngineConfig: &EngineConfig{ |
| 1176 | ID: "codex", |
| 1177 | Version: expressionVersion, |
| 1178 | }, |
| 1179 | } |
| 1180 | |
| 1181 | installSteps := engine.GetInstallationSteps(workflowData) |
| 1182 | |
| 1183 | // Find the npm install step |
| 1184 | var installStep string |
| 1185 | for _, step := range installSteps { |
| 1186 | stepContent := strings.Join(step, "\n") |
| 1187 | if strings.Contains(stepContent, "npm install") { |
| 1188 | installStep = stepContent |
| 1189 | break |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | if installStep == "" { |
| 1194 | t.Fatal("Could not find npm install step") |
| 1195 | } |
| 1196 | |
| 1197 | // Should use ENGINE_VERSION env var for injection safety |
| 1198 | if !strings.Contains(installStep, "ENGINE_VERSION: "+expressionVersion) { |
| 1199 | t.Errorf("Expected ENGINE_VERSION env var in install step, got:\n%s", installStep) |
| 1200 | } |
| 1201 | |
| 1202 | // Should reference env var in command |
| 1203 | if !strings.Contains(installStep, `"${ENGINE_VERSION}"`) { |
| 1204 | t.Errorf(`Expected "$ENGINE_VERSION" in npm install command, got:\n%s`, installStep) |
| 1205 | } |
| 1206 | |
| 1207 | // Should NOT embed expression directly in npm install command |
| 1208 | if strings.Contains(installStep, "@openai/codex@"+expressionVersion) { |
| 1209 | t.Errorf("Expression should NOT be embedded directly in npm install command, got:\n%s", installStep) |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | func TestCodexEngineGetHarnessScriptName(t *testing.T) { |
| 1214 | engine := NewCodexEngine() |
nothing calls this directly
no test coverage detected