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

Function TestCodexEngineWebSearch

pkg/workflow/codex_engine_test.go:1087–1132  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1085}
1086
1087func TestCodexEngineWebSearch(t *testing.T) {
1088 engine := NewCodexEngine()
1089
1090 t.Run("web search disabled by default when tool not specified", func(t *testing.T) {
1091 workflowData := &WorkflowData{
1092 Name: "test-workflow",
1093 }
1094 steps := engine.GetExecutionSteps(workflowData, "test-log")
1095 if len(steps) != 1 {
1096 t.Fatalf("Expected 1 step, got %d", len(steps))
1097 }
1098 stepContent := strings.Join([]string(steps[0]), "\n")
1099 if !strings.Contains(stepContent, `-c web_search="disabled"`) {
1100 t.Errorf(`Expected -c web_search="disabled" config when web-search tool is not specified, got:\n%s`, stepContent)
1101 }
1102 if strings.Contains(stepContent, "--no-search") {
1103 t.Errorf("Expected no --no-search flag (it does not exist), got:\n%s", stepContent)
1104 }
1105 if strings.Contains(stepContent, "--search") {
1106 t.Errorf("Expected no --search flag (it does not exist), got:\n%s", stepContent)
1107 }
1108 })
1109
1110 t.Run("web search enabled when tool is specified", func(t *testing.T) {
1111 workflowData := &WorkflowData{
1112 Name: "test-workflow",
1113 ParsedTools: &ToolsConfig{
1114 WebSearch: &WebSearchToolConfig{},
1115 },
1116 }
1117 steps := engine.GetExecutionSteps(workflowData, "test-log")
1118 if len(steps) != 1 {
1119 t.Fatalf("Expected 1 step, got %d", len(steps))
1120 }
1121 stepContent := strings.Join([]string(steps[0]), "\n")
1122 if strings.Contains(stepContent, `-c web_search="disabled"`) {
1123 t.Errorf(`Expected no -c web_search="disabled" config when web-search tool is specified, got:\n%s`, stepContent)
1124 }
1125 if strings.Contains(stepContent, "--no-search") {
1126 t.Errorf("Expected no --no-search flag (it does not exist), got:\n%s", stepContent)
1127 }
1128 if strings.Contains(stepContent, "--search") {
1129 t.Errorf("Expected no --search flag (it does not exist), got:\n%s", stepContent)
1130 }
1131 })
1132}
1133
1134func TestCodexEngineWebFetch(t *testing.T) {
1135 engine := NewCodexEngine()

Callers

nothing calls this directly

Calls 4

GetExecutionStepsMethod · 0.95
NewCodexEngineFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected