(t *testing.T)
| 101 | } |
| 102 | |
| 103 | func TestCodexEngineWithToolsTimeout(t *testing.T) { |
| 104 | engine := NewCodexEngine() |
| 105 | |
| 106 | tests := []struct { |
| 107 | name string |
| 108 | toolsTimeout string |
| 109 | expectedTimeout string |
| 110 | expectedEnvVar string |
| 111 | }{ |
| 112 | { |
| 113 | name: "default timeout when not specified", |
| 114 | toolsTimeout: "", |
| 115 | expectedTimeout: "tool_timeout_sec = 60", // 60 seconds default |
| 116 | expectedEnvVar: "", // GH_AW_TOOL_TIMEOUT not set when empty |
| 117 | }, |
| 118 | { |
| 119 | name: "custom timeout of 30 seconds", |
| 120 | toolsTimeout: "30", |
| 121 | expectedTimeout: "tool_timeout_sec = 30", |
| 122 | expectedEnvVar: "GH_AW_TOOL_TIMEOUT: 30", // env var in seconds |
| 123 | }, |
| 124 | { |
| 125 | name: "custom timeout of 180 seconds", |
| 126 | toolsTimeout: "180", |
| 127 | expectedTimeout: "tool_timeout_sec = 180", |
| 128 | expectedEnvVar: "GH_AW_TOOL_TIMEOUT: 180", // env var in seconds |
| 129 | }, |
| 130 | { |
| 131 | name: "expression timeout uses default in TOML", |
| 132 | toolsTimeout: "${{ inputs.tool-timeout }}", |
| 133 | expectedTimeout: "tool_timeout_sec = 60", // falls back to default in TOML |
| 134 | expectedEnvVar: "GH_AW_TOOL_TIMEOUT: ${{ inputs.tool-timeout }}", |
| 135 | }, |
| 136 | } |
| 137 | |
| 138 | for _, tt := range tests { |
| 139 | t.Run(tt.name, func(t *testing.T) { |
| 140 | workflowData := &WorkflowData{ |
| 141 | ToolsTimeout: tt.toolsTimeout, |
| 142 | Name: "test-workflow", |
| 143 | Tools: map[string]any{ |
| 144 | "github": map[string]any{}, |
| 145 | }, |
| 146 | } |
| 147 | |
| 148 | // Render MCP config |
| 149 | var configBuilder strings.Builder |
| 150 | mcpTools := []string{"github"} |
| 151 | if err := engine.RenderMCPConfig(&configBuilder, workflowData.Tools, mcpTools, workflowData); err != nil { |
| 152 | t.Fatalf("RenderMCPConfig returned unexpected error: %v", err) |
| 153 | } |
| 154 | configContent := configBuilder.String() |
| 155 | |
| 156 | if !strings.Contains(configContent, tt.expectedTimeout) { |
| 157 | t.Errorf("Expected '%s' in MCP config, got: %s", tt.expectedTimeout, configContent) |
| 158 | } |
| 159 | |
| 160 | // Check for GH_AW_TOOL_TIMEOUT in execution steps |
nothing calls this directly
no test coverage detected