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

Function TestClaudeEngineWithToolsTimeout

pkg/workflow/tools_timeout_test.go:11–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestClaudeEngineWithToolsTimeout(t *testing.T) {
12 engine := NewClaudeEngine()
13
14 tests := []struct {
15 name string
16 toolsTimeout string
17 expectedEnvVar string
18 }{
19 {
20 name: "default timeout when not specified",
21 toolsTimeout: "",
22 expectedEnvVar: "", // GH_AW_TOOL_TIMEOUT not set when empty
23 },
24 {
25 name: "custom timeout of 30 seconds",
26 toolsTimeout: "30",
27 expectedEnvVar: "GH_AW_TOOL_TIMEOUT: 30", // env var in seconds
28 },
29 {
30 name: "custom timeout of 120 seconds",
31 toolsTimeout: "120",
32 expectedEnvVar: "GH_AW_TOOL_TIMEOUT: 120", // env var in seconds
33 },
34 {
35 name: "expression timeout",
36 toolsTimeout: "${{ inputs.tool-timeout }}",
37 expectedEnvVar: "GH_AW_TOOL_TIMEOUT: ${{ inputs.tool-timeout }}",
38 },
39 }
40
41 for _, tt := range tests {
42 t.Run(tt.name, func(t *testing.T) {
43 workflowData := &WorkflowData{
44 ToolsTimeout: tt.toolsTimeout,
45 Tools: map[string]any{},
46 }
47
48 // Get execution steps
49 executionSteps := engine.GetExecutionSteps(workflowData, "/tmp/test.log")
50 if len(executionSteps) == 0 {
51 t.Fatal("Expected at least one execution step")
52 }
53
54 // Check the execution step for timeout environment variables
55 stepContent := strings.Join([]string(executionSteps[0]), "\n")
56
57 // Determine expected timeouts in milliseconds (only for literal values)
58 toolTimeoutMs := 60000 // default for tool operations
59 startupTimeoutMs := 120000 // default for startup
60 if n := templatableIntValue(&tt.toolsTimeout); n > 0 {
61 toolTimeoutMs = n * 1000
62 }
63
64 // Check for MCP_TIMEOUT (uses startup timeout, defaults to 120s)
65 expectedMcpTimeout := fmt.Sprintf("MCP_TIMEOUT: %d", startupTimeoutMs)
66 if !strings.Contains(stepContent, expectedMcpTimeout) {
67 t.Errorf("Expected '%s' in execution step", expectedMcpTimeout)
68 }

Callers

nothing calls this directly

Calls 5

GetExecutionStepsMethod · 0.95
NewClaudeEngineFunction · 0.85
templatableIntValueFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected