package pi import ( "encoding/json" "path/filepath" "strings" "testing" ) // fakepi in the real containment: a Review run reaches its one Equipo // tool through the tool socket, reports its usage and ends. func TestPiFakeReviewInNamespace(t *testing.T) { h := newHarness(t, fakeInstall(t)) work := t.TempDir() r := h.open(work, "inspect", []string{"submit_review", "ask_person"}, "") evs := r.prompt(t, "[Equipo: review] Review this.", "deny") tally := &Tally{} for _, e := range evs { tally.Add(e) } row := tally.Row() if !row.Complete || row.Model != "z-ai/glm-5.3" || *row.InputTokens != 200 { t.Fatalf("usage %+v; events %v", row, kinds(evs)) } calls := r.tools.called() if len(calls) != 1 || !strings.HasPrefix(calls[0], "submit_review ") { t.Fatalf("tool calls %v", calls) } var done Done json.Unmarshal(evs[len(evs)-1].Payload, &done) if done.Status != StatusCompleted { t.Fatalf("done %+v", done) } if err := r.stop(t); err != nil { t.Fatalf("exit not proven: %v", err) } kept := filepath.Join(t.TempDir(), "kept") if n, err := KeepSession(r.home, r.session.ID, kept); err != nil || n == 0 || !HasSession(kept, r.session.ID) { t.Fatalf("session not kept: %d %v", n, err) } }