Skip to content

Commit 4d9536b

Browse files
committed
test(049): make TestConfigFileToolFilter_ReachesRuntime cross-platform
The first revision string-interpolated t.TempDir() into a JSON literal; on windows-amd64 the backslash path produced invalid JSON, failing the test (caught by the Build Binaries windows job). Marshal the config via encoding/json so the path is escaped on every OS. Related #468
1 parent 00c0c74 commit 4d9536b

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

internal/runtime/config_tool_filter_e2e_test.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package runtime
22

33
import (
4+
"encoding/json"
45
"os"
56
"path/filepath"
67
"testing"
@@ -24,10 +25,20 @@ import (
2425
func TestConfigFileToolFilter_ReachesRuntime(t *testing.T) {
2526
dir := t.TempDir()
2627
p := filepath.Join(dir, "mcp_config.json")
27-
require.NoError(t, os.WriteFile(p, []byte(`{
28-
"listen":"127.0.0.1:0","data_dir":"`+dir+`","api_key":"k",
29-
"mcpServers":[{"name":"everything","command":"npx","args":["-y","x"],"protocol":"stdio","enabled":true,"disabled_tools":["echo"]}]
30-
}`), 0600))
28+
// json.Marshal so the data_dir path is correctly escaped on every OS
29+
// (Windows temp paths contain backslashes — raw string interpolation into
30+
// a JSON literal produces invalid JSON).
31+
cfgJSON, err := json.Marshal(map[string]any{
32+
"listen": "127.0.0.1:0",
33+
"data_dir": dir,
34+
"api_key": "k",
35+
"mcpServers": []map[string]any{{
36+
"name": "everything", "command": "npx", "args": []string{"-y", "x"},
37+
"protocol": "stdio", "enabled": true, "disabled_tools": []string{"echo"},
38+
}},
39+
})
40+
require.NoError(t, err)
41+
require.NoError(t, os.WriteFile(p, cfgJSON, 0600))
3142

3243
cfg, err := config.LoadFromFile(p)
3344
require.NoError(t, err)

0 commit comments

Comments
 (0)