Files
MealQuest/internal/store/id_test.go
T
dev_agentandClaude Opus 5.5 59c3cf259d
CI / ci (push) Successful in 50s
CI / ci (pull_request) Successful in 49s
Independent review Codex gpt-6-sol high: CHANGES_REQUIRED (1 medium)
Add store helpers: transactions, ULIDs and time conventions
- Store.WithTx runs fn on the writer, committing on nil and rolling back
  on error, panic or goroutine exit; panics propagate unchanged.
- NewID returns a monotonic ULID string (oklog/ulid/v2, crypto/rand),
  strictly increasing within the process.
- Timestamp stores UTC RFC 3339 TEXT at fixed millisecond precision.
- LocalDate stores YYYY-MM-DD TEXT and rejects invalid or non-canonical
  dates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 08:38:54 -04:00

26 lines
485 B
Go

package store
import (
"testing"
"github.com/oklog/ulid/v2"
)
func TestNewIDStrictlyIncreasing(t *testing.T) {
const n = 10000
prev := NewID()
for range n {
id := NewID()
if len(id) != ulid.EncodedSize {
t.Fatalf("NewID() = %q, want %d characters", id, ulid.EncodedSize)
}
if _, err := ulid.ParseStrict(id); err != nil {
t.Fatalf("NewID() = %q: %v", id, err)
}
if id <= prev {
t.Fatalf("NewID() = %q, not after previous %q", id, prev)
}
prev = id
}
}