MCPcopy Create free account
hub / github.com/Facets-cloud/flow / TestSpawnTabBasicNoEnv

Function TestSpawnTabBasicNoEnv

internal/kitty/kitty_test.go:14–41  ·  view source on GitHub ↗

TestSpawnTabBasicNoEnv verifies the two-call argv sequence with no env vars: 1. RunnerOutput: kitty @ launch --type=tab --tab-title= --cwd= (returns window id) 2. Runner: kitty @ send-text --match=id: " \n" (leading space for histignorespace)

(t *testing.T)

Source from the content-addressed store, hash-verified

12// 1. RunnerOutput: kitty @ launch --type=tab --tab-title=<t> --cwd=<cwd> (returns window id)
13// 2. Runner: kitty @ send-text --match=id:<id> " <command>\n" (leading space for histignorespace)
14func TestSpawnTabBasicNoEnv(t *testing.T) {
15 var launchArgs []string
16 stubRunnerOutput(t, func(args []string) ([]byte, error) {
17 launchArgs = append([]string(nil), args...)
18 return []byte("42\n"), nil
19 })
20
21 var sendArgs []string
22 old := Runner
23 Runner = func(args []string) error {
24 sendArgs = append([]string(nil), args...)
25 return nil
26 }
27 t.Cleanup(func() { Runner = old })
28
29 if err := SpawnTab("my-task", "/tmp", "echo hi", nil); err != nil {
30 t.Fatalf("SpawnTab: %v", err)
31 }
32
33 wantLaunch := []string{"@", "launch", "--type=tab", "--tab-title=my-task", "--cwd=/tmp"}
34 if !slices.Equal(launchArgs, wantLaunch) {
35 t.Errorf("launch argv = %v; want %v", launchArgs, wantLaunch)
36 }
37 wantSend := []string{"@", "send-text", "--match=id:42", " echo hi\n"}
38 if !slices.Equal(sendArgs, wantSend) {
39 t.Errorf("send argv = %v; want %v", sendArgs, wantSend)
40 }
41}
42
43// TestSpawnTabEnvVarsSorted verifies env vars are emitted alphabetically,
44// each value shell-quoted, all space-separated, before the command. This

Callers

nothing calls this directly

Calls 2

stubRunnerOutputFunction · 0.70
SpawnTabFunction · 0.70

Tested by

no test coverage detected