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

Function TestEngineConfigurationWithModel

pkg/workflow/engine_config_test.go:713–784  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

711}
712
713func TestEngineConfigurationWithModel(t *testing.T) {
714 tests := []struct {
715 name string
716 engine CodingAgentEngine
717 engineConfig *EngineConfig
718 expectedModel string
719 expectedAPIKey string
720 }{
721 {
722 name: "Claude with model",
723 engine: NewClaudeEngine(),
724 engineConfig: &EngineConfig{
725 ID: "claude",
726 Model: "claude-3-5-sonnet-20241022",
727 },
728 expectedModel: "claude-3-5-sonnet-20241022",
729 expectedAPIKey: "",
730 },
731 {
732 name: "Codex with model",
733 engine: NewCodexEngine(),
734 engineConfig: &EngineConfig{
735 ID: "codex",
736 Model: "gpt-4o",
737 },
738 expectedModel: "gpt-4o",
739 expectedAPIKey: "",
740 },
741 }
742
743 for _, tt := range tests {
744 t.Run(tt.name, func(t *testing.T) {
745 workflowData := &WorkflowData{
746 Name: "test-workflow",
747 EngineConfig: tt.engineConfig,
748 }
749 steps := tt.engine.GetExecutionSteps(workflowData, "test-log")
750
751 if len(steps) == 0 {
752 t.Fatalf("Expected at least one step, got none")
753 }
754
755 // Convert first step to YAML string for testing
756 stepContent := strings.Join([]string(steps[0]), "\n")
757
758 switch tt.engine.GetID() {
759 case "claude":
760 if tt.expectedModel != "" {
761 // Claude passes model via native ANTHROPIC_MODEL env var
762 expectedEnvLine := "ANTHROPIC_MODEL: " + tt.expectedModel
763 if !strings.Contains(stepContent, expectedEnvLine) {
764 t.Errorf("Expected step to contain env var for model %s, got step content:\n%s", tt.expectedModel, stepContent)
765 }
766 // Should NOT embed --model in the shell command
767 if strings.Contains(stepContent, "--model "+tt.expectedModel) {
768 t.Errorf("Model should not be embedded as --model flag, got step content:\n%s", stepContent)
769 }
770 }

Callers

nothing calls this directly

Calls 6

NewClaudeEngineFunction · 0.85
NewCodexEngineFunction · 0.85
GetExecutionStepsMethod · 0.65
GetIDMethod · 0.65
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected