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.
35 lines
678 B
Go
35 lines
678 B
Go
package claude
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestTailLastNLines_NewestFirst(t *testing.T) {
|
|
dir := t.TempDir()
|
|
p := filepath.Join(dir, "history.jsonl")
|
|
|
|
var b strings.Builder
|
|
for i := 1; i <= 5; i++ {
|
|
b.WriteString("line")
|
|
b.WriteString([]string{"1", "2", "3", "4", "5"}[i-1])
|
|
b.WriteString("\n")
|
|
}
|
|
if err := os.WriteFile(p, []byte(b.String()), 0o600); err != nil {
|
|
t.Fatalf("write: %v", err)
|
|
}
|
|
|
|
lines, err := TailLastNLines(p, 2)
|
|
if err != nil {
|
|
t.Fatalf("TailLastNLines: %v", err)
|
|
}
|
|
if len(lines) != 2 {
|
|
t.Fatalf("len=%d", len(lines))
|
|
}
|
|
if lines[0] != "line5" || lines[1] != "line4" {
|
|
t.Fatalf("got=%v", lines)
|
|
}
|
|
}
|