package index
import "testing"
// The start of a watermark walk over a repository that had nothing when
// the walk began: the earliest check-ins, oldest first.
func TestOldestCheckinsStartsAtTheBeginning(t *testing.T) {
ix := openIndex(t)
if got, err := ix.OldestCheckins(10); err != nil || len(got) != 0 {
t.Fatalf("FAIL: empty repository = %v, %v", got, err)
}
ci(t, ix, "c2", "trunk", "2026-01-02T00:00:00", "second", "c1")
ci(t, ix, "c1", "trunk", "2026-01-01T00:00:00", "first")
ci(t, ix, "c3", "side", "2026-01-03T00:00:00", "third", "c2")
got, err := ix.OldestCheckins(2)
if err != nil {
t.Fatal(err)
}
if len(got) != 2 || got[0].Hash != "c1" || got[1].Hash != "c2" {
t.Fatalf("FAIL: OldestCheckins(2) = %v", got)
}
if got[0].Branch != "trunk" || got[0].Comment != "first" {
t.Errorf("FAIL: row not filled: %+v", got[0])
}
}