package ledger import "testing" func TestValidName(t *testing.T) { for _, ok := range []string{"carbon", "a", "prompt-registry", "x9"} { if !ValidName(ok) { t.Errorf("ValidName(%q) = false, want true", ok) } } for _, bad := range []string{"", "Carbon", "-x", "a_b", "a/b", "café", "0123456789012345678901234567890123456789012345678901234567890123x"} { if ValidName(bad) { t.Errorf("ValidName(%q) = true, want false", bad) } } } func TestKeys(t *testing.T) { if got, want := HeadKey("bab", "platform", "carbon"), "ledgers/bab/platform/carbon/HEAD.json"; got != want { t.Errorf("HeadKey = %q, want %q", got, want) } if got, want := ManifestKey("bab", "platform"), "ledgers/bab/platform/ledgers.json"; got != want { t.Errorf("ManifestKey = %q, want %q", got, want) } if got, want := BlobKey("bab", "platform", "prompts", "abc123"), "ledgers/bab/platform/prompts/blobs/abc123"; got != want { t.Errorf("BlobKey = %q, want %q", got, want) } sha := "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" if got, want := EntryKey("bab", "platform", "carbon", "2026-08-03T21:04:00Z", sha), "ledgers/bab/platform/carbon/entries/20260803T210400Z-0123456789ab.json"; got != want { t.Errorf("EntryKey = %q, want %q", got, want) } }