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

Function TestCodexModelFlagPositionAfterExec

pkg/workflow/model_env_vars_test.go:479–521  ·  view source on GitHub ↗

TestCodexModelFlagPositionAfterExec verifies that the --model flag appears after the exec subcommand in the generated Codex command, not before it. Regression test for: Codex lock compiler places --model flag before exec subcommand.

(t *testing.T)

Source from the content-addressed store, hash-verified

477// subcommand in the generated Codex command, not before it.
478// Regression test for: Codex lock compiler places --model flag before exec subcommand.
479func TestCodexModelFlagPositionAfterExec(t *testing.T) {
480 workflowData := &WorkflowData{
481 Name: "test-codex-model-position",
482 AI: "codex",
483 Tools: map[string]any{
484 "bash": []any{"echo"},
485 },
486 SafeOutputs: &SafeOutputsConfig{},
487 }
488
489 engine, err := GetGlobalEngineRegistry().GetEngine("codex")
490 if err != nil {
491 t.Fatalf("Failed to get engine: %v", err)
492 }
493
494 steps := engine.GetExecutionSteps(workflowData, "/tmp/test.log")
495
496 var stepsStr strings.Builder
497 for _, step := range steps {
498 for _, line := range step {
499 stepsStr.WriteString(line)
500 stepsStr.WriteString("\n")
501 }
502 }
503 stepsContent := stepsStr.String()
504
505 // Find the model shell expansion pattern in the generated command
506 modelPattern := "${" + constants.EnvVarModelAgentCodex + ":+"
507 beforeModel, _, found := strings.Cut(stepsContent, modelPattern)
508 if !found {
509 t.Fatalf("Model expansion pattern '%s' not found in steps:\n%s", modelPattern, stepsContent)
510 }
511
512 // Find "codex exec" before the model pattern. Using "codex exec" (not just "exec") avoids
513 // false positives from unrelated occurrences like "GH_AW_NODE_EXEC" in the step content.
514 execMarker := "codex exec"
515 execIdx := strings.LastIndex(beforeModel, execMarker)
516 if execIdx == -1 {
517 t.Errorf("'codex exec' must appear before the model flag '%s' in the generated command.\n"+
518 "This indicates the model flag is placed before 'exec', causing Codex to ignore it.\n"+
519 "Got:\n%s", modelPattern, stepsContent)
520 }
521}

Callers

nothing calls this directly

Calls 5

GetGlobalEngineRegistryFunction · 0.85
GetEngineMethod · 0.80
GetExecutionStepsMethod · 0.65
StringMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected