package index
import "testing"
// A check-in that arrives after the watermark but carries an older
// date is still new: the cursor is arrival order, not check-in date.
func TestCheckinsAfterSeesAnOlderDatedArrival(t *testing.T) {
ix := openIndex(t)
ci(t, ix, "c1", "trunk", "2026-01-01T00:00:00", "first")
ci(t, ix, "c3", "trunk", "2026-01-03T00:00:00", "newer", "c1")
ci(t, ix, "c2", "side", "2026-01-02T00:00:00", "older, arrived late", "c1")
got, err := ix.CheckinsAfter("c3", 10)
if err != nil {
t.Fatal(err)
}
if len(got) != 1 || got[0].Hash != "c2" {
t.Fatalf("FAIL: CheckinsAfter(c3) = %v, want c2", got)
}
}
// Two check-ins with the same date are both seen; a strict date
// comparison would drop the second.
func TestCheckinsAfterSeesASameDateArrival(t *testing.T) {
ix := openIndex(t)
ci(t, ix, "a", "trunk", "2026-01-01T00:00:00", "a")
ci(t, ix, "b", "side", "2026-01-01T00:00:00", "b")
got, err := ix.CheckinsAfter("a", 10)
if err != nil || len(got) != 1 || got[0].Hash != "b" {
t.Fatalf("FAIL: CheckinsAfter(a) = %v, %v", got, err)
}
}