MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / TestLoop_ChiefDoneEvent

Function TestLoop_ChiefDoneEvent

internal/loop/loop_test.go:335–379  ·  view source on GitHub ↗

TestLoop_ChiefDoneEvent tests detection of event.

(t *testing.T)

Source from the content-addressed store, hash-verified

333
334// TestLoop_ChiefDoneEvent tests detection of <chief-done/> event.
335func TestLoop_ChiefDoneEvent(t *testing.T) {
336 l := NewLoop("/test/prd.json", "test", 5, testProvider)
337 l.iteration = 1
338
339 done := make(chan bool)
340 var events []Event
341 go func() {
342 for event := range l.Events() {
343 events = append(events, event)
344 if event.Type == EventStoryDone {
345 break
346 }
347 }
348 done <- true
349 }()
350
351 // Simulate processing a line with chief-done
352 r, w, _ := os.Pipe()
353 go func() {
354 w.WriteString(`{"type":"assistant","message":{"content":[{"type":"text","text":"All criteria pass! <chief-done/>"}]}}` + "\n")
355 w.Close()
356 }()
357
358 l.processOutput(r)
359 close(l.events)
360 <-done
361
362 // Check that we got a StoryDone event and sawStoryDone was set
363 hasStoryDone := false
364 for _, e := range events {
365 if e.Type == EventStoryDone {
366 hasStoryDone = true
367 }
368 }
369
370 if !hasStoryDone {
371 t.Error("Expected StoryDone event for <chief-done/>")
372 }
373
374 l.mu.Lock()
375 if !l.sawStoryDone {
376 t.Error("Expected sawStoryDone to be true after processing <chief-done/>")
377 }
378 l.mu.Unlock()
379}
380
381// TestLoop_SetMaxIterations tests setting max iterations at runtime.
382func TestLoop_SetMaxIterations(t *testing.T) {

Callers

nothing calls this directly

Calls 3

EventsMethod · 0.95
processOutputMethod · 0.95
NewLoopFunction · 0.85

Tested by

no test coverage detected