Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536package db
import ( "context" "fmt" "strings" "testing")
func TestTotalIsCountedOnceForAListing(t *testing.T) { d := newTestDB(t) ctx := context.Background() const repo = "did:plc:totals" for i := range 5 { seedPipeline(t, d, fmt.Sprintf("early-%d", i), repo, "push") }
_, cursor, total, err := d.QueryPipelines(ctx, repo, nil, "", nil, 2) if err != nil || total != 5 || cursor == "" { t.Fatalf("first page: total %d, cursor %q (%v), want 5 and a cursor", total, cursor, err) } for i := range 3 { seedPipeline(t, d, fmt.Sprintf("late-%d", i), repo, "push") }
_, _, total, err = d.QueryPipelines(ctx, repo, nil, cursor, nil, 2) if err != nil || total != 5 { t.Fatalf("second page total = %d (%v), want the 5 the first page counted", total, err) }
plain, _, _ := strings.Cut(cursor, ":") if _, _, total, err = d.QueryPipelines(ctx, repo, nil, plain, nil, 2); err != nil || total != 8 { t.Fatalf("plain cursor total = %d (%v), want 8", total, err) }}