Files
Agent-System/internal/app/app_test.go
T
weichenandCursor 84c0841acb feat(app): add composition root, stageflow, ContextUpdate, and SSE transport
Move construction and document OnOutbox out of server, give HTTP/CLI a shared task use case, and block already-cleared import/event arch rules.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-15 05:40:15 +00:00

45 lines
939 B
Go

package app
import (
"context"
"testing"
"time"
)
func TestStartStopRestartIdempotent(t *testing.T) {
rt := &Runtime{}
ctx := context.Background()
if err := rt.Start(ctx); err != nil {
t.Fatal(err)
}
if err := rt.Start(ctx); err != nil {
t.Fatal(err)
}
if rt.StartCount() != 1 {
t.Fatalf("duplicate Start spawned workers: starts=%d", rt.StartCount())
}
if got := rt.SubscriberCount(); got != 1 {
t.Fatalf("subscribers=%d", got)
}
if !rt.Running() {
t.Fatal("expected running")
}
if err := rt.Stop(ctx); err != nil {
t.Fatal(err)
}
if rt.Running() {
t.Fatal("expected stopped")
}
if err := rt.Start(ctx); err != nil {
t.Fatal(err)
}
if rt.StartCount() != 2 {
t.Fatalf("restart did not relaunch worker: starts=%d", rt.StartCount())
}
if rt.SubscriberCount() != 1 {
t.Fatalf("restart re-registered subscribers: %d", rt.SubscriberCount())
}
_ = rt.Stop(ctx)
time.Sleep(10 * time.Millisecond)
}