oficina / fichas Public

Cursor tests: ids of 0 or below, and a catalogue event (Astra, round 2)

Removing canonicalPositive's n < 1 bound was not equivalent: "0.1" and
"-1.1" skipped the lookup and paged from the beginning. And a correctly
stamped non-card event was never tested as a cursor. Both mutants red.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev eabbe17f22aeaf570994f679e017c186b7076a80 parent d3f63a4
1 file changed, +25 −4
  • internal/fichas/suite_test.go +25 −4

CI passed — run details

diff --git a/internal/fichas/suite_test.go b/internal/fichas/suite_test.go
index ef895e6..08b0a72 100644
--- a/internal/fichas/suite_test.go
+++ b/internal/fichas/suite_test.go
@@ -7,6 +7,7 @@ import (
"strconv"
"strings"
"testing"
+ "time"
"gorm.io/gorm"
@@ -205,10 +206,13 @@ func TestSuiteFeedOnAnEmptyLog(t *testing.T) {
// from canonicalPositive → "leading zero"/"plus"; a bare event id accepted
// as a cursor AND the lookup skipped for it → "no stamp"; the cursor's
// event lookup skipped → "ahead"/"wrong stamp"; the stamp comparison
-// removed → "wrong stamp". Two mutants survive and are equivalent: a bare
-// id parsed as stamp 0 (the lookup then refuses it), and canonicalPositive's
-// n < 1 bound removed (no event or card has a zero or negative id or
-// stamp, so the lookup refuses those too).
+// removed → "wrong stamp"; canonicalPositive's n < 1 bound removed →
+// "zero id"/"negative id" (Astra, 2026-11-01: not equivalent — an id of 0
+// or below skips the lookup and pages from the beginning); the lookup's
+// object_kind = card restriction removed → "a catalogue event" (a correctly
+// stamped event that is not a card's would have been accepted). One mutant
+// survives and is equivalent: a bare id parsed as stamp 0, which the lookup
+// then refuses.
func TestSuiteFeedRefusesACursorItNeverIssued(t *testing.T) {
g, a, p := suiteWorld(t)
mustCard(t, g, a, map[string]string{FieldName: "Cnoc Teoranta"})
@@ -228,11 +232,28 @@ func TestSuiteFeedRefusesACursorItNeverIssued(t *testing.T) {
"spaces": " " + tip,
"ahead": stampedID(n+1000, stamp),
"wrong stamp": stampedID(n, stamp+1),
+ "zero id": "0.1",
+ "negative id": "-1.1",
} {
if f, err := p.Feed(ctx(), c, 10); err == nil {
t.Errorf("%s: cursor %q answered %+v, want an error", name, c, f)
}
}
+
+ // A catalogue event, correctly stamped, is still not a feed position:
+ // the feed is card events only, so its ids are not positions in it.
+ other := Event{Kind: EventUpdated, ObjectKind: ObjectType, ObjectID: 1, Revision: 1, CreatedAt: time.Now().UTC()}
+ if err := g.Create(&other).Error; err != nil {
+ t.Fatalf("seeding a catalogue event: %v", err)
+ }
+ var stored Event
+ if err := g.First(&stored, other.ID).Error; err != nil {
+ t.Fatal(err)
+ }
+ c := stampedID(stored.ID, stored.CreatedAt.UnixNano())
+ if f, err := p.Feed(ctx(), c, 10); err == nil {
+ t.Errorf("a catalogue event: cursor %q answered %+v, want an error", c, f)
+ }
}
// S2, every branch of spec §6.3's table.