package main
import (
"bytes"
"encoding/json"
"strings"
"testing"
)
// resetGlobals resets global state before each test
func resetGlobals() {
pausedMu.Lock()
paused = false
pausedMu.Unlock()
minAmplitude = 0.05
cooldownMs = 750
stdioMode = true
}
func TestPauseCommand(t *testing.T) {
resetGlobals()
input := `{"cmd":"pause"}` + "\n"
var output bytes.Buffer
processCommands(strings.NewReader(input), &output)
// Check state changed
pausedMu.RLock()
if !paused {
t.Error("expected paused to be true after pause command")
}
pausedMu.RUnlock()
// Check output
var resp map[string]string
if err := json.Unmarshal(output.Bytes(), &resp); err != nil {
t.Fatalf("failed to parse response: %v", err)
}
if resp["status"] != "paused" {