MCPcopy Create free account
hub / github.com/compozy/agh / TestSpawnDetachedDaemonProcess

Function TestSpawnDetachedDaemonProcess

internal/cli/daemon_exec_test.go:14–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestSpawnDetachedDaemonProcess(t *testing.T) {
15 t.Parallel()
16
17 homePaths, err := aghconfig.ResolveHomePathsFrom(t.TempDir())
18 if err != nil {
19 t.Fatalf("ResolveHomePathsFrom() error = %v", err)
20 }
21
22 scriptPath := filepath.Join(t.TempDir(), "agh-test-daemon.sh")
23 if err := os.WriteFile(scriptPath, []byte("#!/bin/sh\nexit 0\n"), 0o755); err != nil {
24 t.Fatalf("os.WriteFile(script) error = %v", err)
25 }
26
27 process, err := spawnDetachedDaemonProcess(context.Background(), homePaths, func() (string, error) {
28 return scriptPath, nil
29 })
30 if err != nil {
31 t.Fatalf("spawnDetachedDaemonProcess() error = %v", err)
32 }
33 if process.PID() <= 0 {
34 t.Fatalf("process.PID() = %d, want positive pid", process.PID())
35 }
36 if err := process.Wait(); err != nil {
37 t.Fatalf("process.Wait() error = %v", err)
38 }
39}
40
41func TestSpawnDetachedDaemonProcessWaitIncludesStderr(t *testing.T) {
42 t.Parallel()

Callers

nothing calls this directly

Calls 4

WriteFileMethod · 0.65
PIDMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected