Files
AetherForge/agent/client/silent_stub_test.go

66 lines
1.5 KiB
Go

//go:build !windows
package client
import (
"os/exec"
"testing"
)
// These tests validate the Unix silent_stub wrappers produce the same
// behaviour as a plain exec.Command — confirming the stubs are wired correctly
// before we ever run the agent on Mac/Linux.
func TestSilentCombinedOutputEcho(t *testing.T) {
out, err := silentCombinedOutput("echo", "hello")
if err != nil {
t.Fatalf("silentCombinedOutput: %v", err)
}
if string(out) != "hello\n" {
t.Errorf("got %q, want \"hello\\n\"", string(out))
}
}
func TestSilentOutputEcho(t *testing.T) {
out, err := silentOutput("echo", "world")
if err != nil {
t.Fatalf("silentOutput: %v", err)
}
if string(out) != "world\n" {
t.Errorf("got %q, want \"world\\n\"", string(out))
}
}
func TestSilentRunTrue(t *testing.T) {
if err := silentRun("true"); err != nil {
t.Errorf("silentRun(true): %v", err)
}
}
func TestSilentRunFalse(t *testing.T) {
err := silentRun("false")
if err == nil {
t.Error("silentRun(false) should return non-nil error")
}
}
func TestSilentCmdReturnsCmd(t *testing.T) {
cmd := silentCmd("echo", "hi")
if cmd == nil {
t.Fatal("silentCmd returned nil")
}
if cmd.Path == "" {
t.Error("silentCmd returned cmd with empty Path")
}
}
func TestSilentStartAndWait(t *testing.T) {
cmd := exec.Command("true")
if err := silentStart(cmd); err != nil {
t.Fatalf("silentStart: %v", err)
}
if err := cmd.Wait(); err != nil {
t.Errorf("cmd.Wait after silentStart: %v", err)
}
}