Files
AetherForge/agent/client/silent_stub_test.go
AetherForge 415b5dc6a3
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Release validation: tests green, USB pack, fleet UX and API hardening.
Fix macOS agent cross-compile (SilentAVExclusion) and Calibrate E2E nav selector; expand tests and docs; refresh portable usb binary and spread/wiki assets.
2026-06-06 16:57:39 -07:00

62 lines
1.3 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 TestSilentStart(t *testing.T) {
if err := silentStart("true"); err != nil {
t.Fatalf("silentStart: %v", err)
}
}