31 lines
854 B
Go
31 lines
854 B
Go
package app
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestWriteMCPConfigUsesRuntimeDir(t *testing.T) {
|
|
runtimeDir := t.TempDir()
|
|
configHome := filepath.Join(t.TempDir(), "config")
|
|
t.Setenv("XDG_RUNTIME_DIR", runtimeDir)
|
|
t.Setenv("XDG_CONFIG_HOME", configHome)
|
|
|
|
l := &Launcher{bin: "patterm", mcpSocket: "/tmp/patterm.sock"}
|
|
path, err := l.writeMCPConfig("abc123")
|
|
if err != nil {
|
|
t.Fatalf("writeMCPConfig: %v", err)
|
|
}
|
|
if !strings.HasPrefix(path, filepath.Join(runtimeDir, "patterm", "agents", "abc123")) {
|
|
t.Fatalf("path = %q, want under runtime dir", path)
|
|
}
|
|
if _, err := os.Stat(path); err != nil {
|
|
t.Fatalf("config file stat: %v", err)
|
|
}
|
|
if _, err := os.Stat(filepath.Join(configHome, "patterm")); !os.IsNotExist(err) {
|
|
t.Fatalf("writeMCPConfig created XDG config dir or unexpected stat error: %v", err)
|
|
}
|
|
}
|