Add comprehensive Claude Code monitoring and realtime streaming to the K8s dashboard. Includes API endpoints for health, stats, summary, inventory, and live event streaming. Frontend provides overview, usage, inventory, debug, and live feed views.
41 lines
782 B
Go
41 lines
782 B
Go
package claude
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestHistoryTailer_EmitsOnAppend(t *testing.T) {
|
|
dir := t.TempDir()
|
|
p := filepath.Join(dir, "history.jsonl")
|
|
if err := os.WriteFile(p, []byte(""), 0o600); err != nil {
|
|
t.Fatalf("write: %v", err)
|
|
}
|
|
|
|
hub := NewEventHub(10)
|
|
ch, cancel := hub.Subscribe()
|
|
defer cancel()
|
|
|
|
stop := make(chan struct{})
|
|
go TailHistoryFile(stop, hub, p)
|
|
|
|
time.Sleep(600 * time.Millisecond)
|
|
|
|
if err := os.WriteFile(p, []byte("{\"display\":\"/status\"}\n"), 0o600); err != nil {
|
|
t.Fatalf("append: %v", err)
|
|
}
|
|
|
|
select {
|
|
case ev := <-ch:
|
|
if ev.Type != EventTypeHistoryAppend {
|
|
t.Fatalf("type=%s", ev.Type)
|
|
}
|
|
case <-time.After(700 * time.Millisecond):
|
|
t.Fatalf("timed out waiting for event")
|
|
}
|
|
|
|
close(stop)
|
|
}
|