Files
archie/internal/store/review_cursor_test.go
T
sam a65eae2458 docs(agents): a bead never carries production instance detail
Beads sync to a Dolt remote, so anything written into one is published.
Two beads filed earlier today named an operator host, its internal
address and its filesystem paths -- the tracker was treated as a private
store, which it is not.

The rule is stated where the tracker is described, next to the existing
one about .beads/ never reaching a commit, because it is the same class:
the tracker is not a private store. Host-specific facts belong in the
operator's memos instance, which a bead may point at.
2026-09-23 12:29:29 +10:00

46 lines
1.6 KiB
Go

package store
import (
"errors"
"testing"
"github.com/samcharles93/archie-core/internal/domain/workflow"
)
// TestOpenPRsCarriesReviewCursors pins the poll backstop's read side: the
// per-PR scan reads each task's persisted review and comment cursors, so a
// daemon restart resumes where the last scan stopped instead of re-listing
// every review the forge has ever returned.
func TestOpenPRsCarriesReviewCursors(t *testing.T) {
s := openTest(t)
id := prOpenTask(t, s, "acme", "widgets", 42)
if err := s.SetReviewCursors(t.Context(), id, 100, 200); err != nil {
t.Fatalf("SetReviewCursors: %v", err)
}
tasks, err := s.OpenPRs(t.Context())
if err != nil || len(tasks) != 1 {
t.Fatalf("OpenPRs = (%d tasks, %v), want 1", len(tasks), err)
}
if tasks[0].ReviewCursor != 100 {
t.Errorf("ReviewCursor = %d, want 100", tasks[0].ReviewCursor)
}
if tasks[0].WatchCommentID != 200 {
t.Errorf("WatchCommentID = %d, want 200 (the review-comment cursor)", tasks[0].WatchCommentID)
}
}
// TestSetReviewCursorsGuardsOnStatus pins the write side: cursors only move
// while the task is idle in pr_open. A cursor written under a running or
// parked task would desync from what its remediation run has consumed.
func TestSetReviewCursorsRefusesNonOpenPRStatuses(t *testing.T) {
s := openTest(t)
id := prOpenTask(t, s, "acme", "widgets", 42)
if err := s.Transition(t.Context(), id, workflow.StatusPROpen, workflow.StatusParked, "gate failed"); err != nil {
t.Fatal(err)
}
if err := s.SetReviewCursors(t.Context(), id, 5, 6); !errors.Is(err, ErrStaleTransition) {
t.Errorf("SetReviewCursors on parked err = %v, want ErrStaleTransition", err)
}
}