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

Function TestModelEnvVarInjectionForAgentJob

pkg/workflow/model_env_vars_test.go:14–97  ·  view source on GitHub ↗

TestModelEnvVarInjectionForAgentJob tests that agent jobs get the correct model environment variable

(t *testing.T)

Source from the content-addressed store, hash-verified

12
13// TestModelEnvVarInjectionForAgentJob tests that agent jobs get the correct model environment variable
14func TestModelEnvVarInjectionForAgentJob(t *testing.T) {
15 tests := []struct {
16 name string
17 engine string
18 expectedEnvVar string
19 expectedCommand string
20 expectedDefault string
21 expectedDefaultOverride string
22 }{
23 {
24 name: "Claude agent uses GH_AW_MODEL_AGENT_CLAUDE",
25 engine: "claude",
26 expectedEnvVar: constants.EnvVarModelAgentClaude,
27 expectedCommand: "${" + constants.EnvVarModelAgentClaude + ":+ --model",
28 expectedDefault: "", // Claude has no default model
29 expectedDefaultOverride: compilerenv.DefaultModelClaude,
30 },
31 {
32 name: "Codex agent uses GH_AW_MODEL_AGENT_CODEX",
33 engine: "codex",
34 expectedEnvVar: constants.EnvVarModelAgentCodex,
35 expectedCommand: "${" + constants.EnvVarModelAgentCodex + `:+ --model "`,
36 expectedDefault: constants.CodexDefaultModel,
37 expectedDefaultOverride: compilerenv.DefaultModelCodex,
38 },
39 }
40
41 for _, tt := range tests {
42 t.Run(tt.name, func(t *testing.T) {
43 // Create a simple workflow with the specified engine
44 // Add SafeOutputs to distinguish from detection jobs
45 workflowData := &WorkflowData{
46 Name: "test-workflow",
47 AI: tt.engine,
48 Tools: map[string]any{
49 "bash": []any{"echo"},
50 },
51 SafeOutputs: &SafeOutputsConfig{
52 // Just enough to make it an agent job
53 },
54 }
55
56 // Get the engine
57 engine, err := GetGlobalEngineRegistry().GetEngine(tt.engine)
58 if err != nil {
59 t.Fatalf("Failed to get engine: %v", err)
60 }
61
62 // Get execution steps
63 steps := engine.GetExecutionSteps(workflowData, "/tmp/test.log")
64
65 // Convert steps to string for analysis
66 var stepsStr strings.Builder
67 for _, step := range steps {
68 for _, line := range step {
69 stepsStr.WriteString(line)
70 stepsStr.WriteString("\n")
71 }

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected