Files
beads/cmd/bd/agent_test.go
Steve Yegge 947b5ee1c6 feat: add bd agent state command for ZFC-compliant state reporting (bd-uxlb)
Add agent commands for self-reporting state:
- bd agent state <agent> <state>: Update agent state and last_activity
- bd agent heartbeat <agent>: Update last_activity timestamp only
- bd agent show <agent>: Display agent bead details

States: idle, spawning, running, working, stuck, done, stopped, dead

Also adds AgentState and LastActivity fields to UpdateArgs in RPC protocol.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 01:56:53 -08:00

51 lines
1.1 KiB
Go

package main
import (
"testing"
)
func TestValidAgentStates(t *testing.T) {
// Test that all expected states are valid
expectedStates := []string{
"idle", "spawning", "running", "working",
"stuck", "done", "stopped", "dead",
}
for _, state := range expectedStates {
if !validAgentStates[state] {
t.Errorf("expected state %q to be valid, but it's not", state)
}
}
}
func TestInvalidAgentStates(t *testing.T) {
// Test that invalid states are rejected
invalidStates := []string{
"starting", "waiting", "active", "inactive",
"unknown", "error", "RUNNING", "Idle",
}
for _, state := range invalidStates {
if validAgentStates[state] {
t.Errorf("expected state %q to be invalid, but it's valid", state)
}
}
}
func TestAgentStateCount(t *testing.T) {
// Verify we have exactly 8 valid states
expectedCount := 8
actualCount := len(validAgentStates)
if actualCount != expectedCount {
t.Errorf("expected %d valid states, got %d", expectedCount, actualCount)
}
}
func TestFormatTimeOrNil(t *testing.T) {
// Test nil case
result := formatTimeOrNil(nil)
if result != nil {
t.Errorf("expected nil for nil time, got %v", result)
}
}