Harden item occurrence grounding

This commit is contained in:
2026-08-06 13:37:21 +00:00
parent 8cf03a2a44
commit 4192aa8584
16 changed files with 152 additions and 121 deletions

View File

@@ -9,29 +9,6 @@ import (
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
)
func TestComparisonKeyNormalizesSupportedEquivalences(t *testing.T) {
tests := []struct {
name string
left string
right string
}{
{name: "case", left: "Silver Key", right: "sILVER kEY"},
{name: "compatibility", left: " ", right: "Silver Key"},
{name: "whitespace", left: " Silver\u2003Key ", right: "Silver Key"},
{name: "apostrophe", left: "Healers Kit", right: "healer's kit"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if ComparisonKey(test.left) != ComparisonKey(test.right) {
t.Fatalf("ComparisonKey(%q) = %q, ComparisonKey(%q) = %q", test.left, ComparisonKey(test.left), test.right, ComparisonKey(test.right))
}
})
}
if ComparisonKey("Silver Key") == ComparisonKey("Gold Key") {
t.Fatal("different item types received the same comparison key")
}
}
func TestDeriveIDUsesExactCompactIdentityBytes(t *testing.T) {
const wantID = "item:sha256:2f211c60b9bdcf3a6dd64086cc4c05df5b3357ae02cb462f7ef8988d9bd2fa4f"
const wantIdentity = `["dnd.item_registry.identity.v1","silver key"]`