@@ -7,144 +7,6 @@ import (
77 "testing"
88)
99
10- // TestRenderSafeOutputsMCPConfigShared tests the shared renderSafeOutputsMCPConfig function
11- func TestRenderSafeOutputsMCPConfigShared (t * testing.T ) {
12- tests := []struct {
13- name string
14- isLast bool
15- wantContains []string
16- wantEnding string
17- }{
18- {
19- name : "safe outputs config not last" ,
20- isLast : false ,
21- wantContains : []string {
22- `"safeoutputs": {` ,
23- `"type": "http"` ,
24- `"url": "http://host.docker.internal:$GH_AW_SAFE_OUTPUTS_PORT"` ,
25- `"headers": {` ,
26- `"Authorization": "$GH_AW_SAFE_OUTPUTS_API_KEY"` ,
27- },
28- wantEnding : "},\n " ,
29- },
30- {
31- name : "safe outputs config is last" ,
32- isLast : true ,
33- wantContains : []string {
34- `"safeoutputs": {` ,
35- `"type": "http"` ,
36- `"url": "http://host.docker.internal:$GH_AW_SAFE_OUTPUTS_PORT"` ,
37- },
38- wantEnding : "}\n " ,
39- },
40- }
41-
42- for _ , tt := range tests {
43- t .Run (tt .name , func (t * testing.T ) {
44- var yaml strings.Builder
45- renderSafeOutputsMCPConfig (& yaml , tt .isLast , nil )
46-
47- result := yaml .String ()
48-
49- // Check all required strings are present
50- for _ , want := range tt .wantContains {
51- if ! strings .Contains (result , want ) {
52- t .Errorf ("renderSafeOutputsMCPConfig() result missing %q\n Got:\n %s" , want , result )
53- }
54- }
55-
56- // Check correct ending
57- if ! strings .HasSuffix (result , tt .wantEnding ) {
58- // Show last part of result for debugging, but handle short strings
59- endSnippet := result
60- if len (result ) > 10 {
61- endSnippet = result [len (result )- 10 :]
62- }
63- t .Errorf ("renderSafeOutputsMCPConfig() ending = %q, want suffix %q" , endSnippet , tt .wantEnding )
64- }
65- })
66- }
67- }
68-
69- // TestRenderCustomMCPConfigWrapperShared tests the shared renderCustomMCPConfigWrapper function
70- func TestRenderCustomMCPConfigWrapperShared (t * testing.T ) {
71- tests := []struct {
72- name string
73- toolName string
74- toolConfig map [string ]any
75- isLast bool
76- wantContains []string
77- wantEnding string
78- wantError bool
79- }{
80- {
81- name : "custom MCP config not last" ,
82- toolName : "my-tool" ,
83- toolConfig : map [string ]any {
84- "command" : "node" ,
85- "args" : []string {"server.js" },
86- },
87- isLast : false ,
88- wantContains : []string {
89- `"my-tool": {` ,
90- `"command": "node"` ,
91- },
92- wantEnding : "},\n " ,
93- wantError : false ,
94- },
95- {
96- name : "custom MCP config is last" ,
97- toolName : "another-tool" ,
98- toolConfig : map [string ]any {
99- "command" : "python" ,
100- "args" : []string {"-m" , "server" },
101- },
102- isLast : true ,
103- wantContains : []string {
104- `"another-tool": {` ,
105- `"command": "python"` ,
106- },
107- wantEnding : "}\n " ,
108- wantError : false ,
109- },
110- }
111-
112- for _ , tt := range tests {
113- t .Run (tt .name , func (t * testing.T ) {
114- var yaml strings.Builder
115- err := renderCustomMCPConfigWrapper (& yaml , tt .toolName , tt .toolConfig , tt .isLast )
116-
117- if (err != nil ) != tt .wantError {
118- t .Errorf ("renderCustomMCPConfigWrapper() error = %v, wantError %v" , err , tt .wantError )
119- return
120- }
121-
122- if tt .wantError {
123- return
124- }
125-
126- result := yaml .String ()
127-
128- // Check all required strings are present
129- for _ , want := range tt .wantContains {
130- if ! strings .Contains (result , want ) {
131- t .Errorf ("renderCustomMCPConfigWrapper() result missing %q\n Got:\n %s" , want , result )
132- }
133- }
134-
135- // Check correct ending
136- if ! strings .HasSuffix (result , tt .wantEnding ) {
137- // Show last part of result for debugging, but handle short strings
138- endSnippet := result
139- if len (result ) > 10 {
140- endSnippet = result [len (result )- 10 :]
141- }
142- t .Errorf ("renderCustomMCPConfigWrapper() ending = %q, want suffix %q" , endSnippet , tt .wantEnding )
143- }
144- })
145- }
146- }
147-
14810// TestEngineMethodsDelegateToShared ensures engine methods properly delegate to shared functions
14911func TestEngineMethodsDelegateToShared (t * testing.T ) {
15012 t .Run ("Claude engine Playwright delegation via unified renderer" , func (t * testing.T ) {
0 commit comments