Files
wehub-resource-sync f99010fae1
CI / lint (push) Failing after 1s
CI / frontend (push) Failing after 1s
CI / scripts (push) Failing after 1s
CI / Go Test (ubuntu-latest) (push) Failing after 0s
CI / frontend-node-25 (push) Failing after 1s
CI / docs (push) Failing after 0s
CI / coverage (push) Failing after 0s
CI / e2e (push) Failing after 0s
Docker / build-and-push (push) Failing after 1s
CI / integration (push) Failing after 4m43s
CI / Go Test (windows-latest) (push) Has been cancelled
CI / Desktop Unit Tests (Windows) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux (arm64)) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Windows) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (aarch64)) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (x86_64)) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:30:36 +08:00

99 lines
2.6 KiB
Go

package server
import (
"runtime"
"slices"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestLaunchResumeDarwinGhosttyDirectCli(t *testing.T) {
cwd := t.TempDir()
proc := launchResumeDarwin(
Opener{
ID: "ghostty",
Name: "Ghostty",
Kind: "terminal",
Bin: "/usr/local/bin/ghostty",
},
"cursor agent --resume chat-1",
cwd,
)
require.NotNil(t, proc, "launchResumeDarwin returned nil")
assert.False(t, strings.HasSuffix(proc.Args[0], "osascript"),
"expected direct CLI, got osascript: %v", proc.Args)
wantWD := "--working-directory=" + cwd
assert.True(t, sliceContains(proc.Args, wantWD),
"missing %q in args: %v", wantWD, proc.Args)
}
func TestLaunchResumeDarwinGhosttyAppBundle(t *testing.T) {
cwd := t.TempDir()
proc := launchResumeDarwin(
Opener{
ID: "ghostty",
Name: "Ghostty",
Kind: "terminal",
Bin: "/Applications/Ghostty.app",
},
"cursor agent --resume chat-1",
cwd,
)
require.NotNil(t, proc, "launchResumeDarwin returned nil")
// App bundle wraps with `open -na`.
assert.True(t, strings.HasSuffix(proc.Args[0], "open"),
"expected open for app bundle, got %q", proc.Args[0])
assert.True(t, sliceContains(proc.Args, "-na"),
"missing -na flag: %v", proc.Args)
wantWD := "--working-directory=" + cwd
assert.True(t, sliceContains(proc.Args, wantWD),
"missing %q in args: %v", wantWD, proc.Args)
}
func TestLaunchResumeDarwinGhosttyNoCwd(t *testing.T) {
proc := launchResumeDarwin(
Opener{
ID: "ghostty",
Name: "Ghostty",
Kind: "terminal",
Bin: "/usr/local/bin/ghostty",
},
"cursor agent --resume chat-1",
"",
)
require.NotNil(t, proc, "launchResumeDarwin returned nil")
for _, arg := range proc.Args {
assert.False(t, strings.HasPrefix(arg, "--working-directory"),
"unexpected --working-directory with empty cwd: %v", proc.Args)
}
}
func TestLaunchTerminalInDirGhosttyDirectCliOnDarwin(t *testing.T) {
if runtime.GOOS != "darwin" {
t.Skip("macOS-specific Ghostty launch path")
}
dir := t.TempDir()
proc := launchTerminalInDir(
Opener{
ID: "ghostty",
Name: "Ghostty",
Kind: "terminal",
Bin: "/Applications/Ghostty.app",
},
dir,
)
require.NotNil(t, proc, "launchTerminalInDir returned nil")
assert.False(t, strings.HasSuffix(proc.Args[0], "osascript"),
"expected direct launch, got osascript: %v", proc.Args)
wantWD := "--working-directory=" + dir
assert.True(t, sliceContains(proc.Args, wantWD),
"missing %q in args: %v", wantWD, proc.Args)
}
func sliceContains(ss []string, s string) bool {
return slices.Contains(ss, s)
}