Ground location occurrences with contextual selectors
This commit is contained in:
@@ -14,36 +14,26 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/locations/identity"
|
||||
)
|
||||
|
||||
func TestResolveUnboundRegistryHasEmptyProjection(t *testing.T) {
|
||||
func TestResolveUnboundRegistryHasEmptyIdentity(t *testing.T) {
|
||||
registry, err := Resolve(contracts.ReferenceSet{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
input := registry.PromptInput()
|
||||
if registry.Bound() || registry.Digest() != "" || registry.Count() != 0 || string(input.Content) != emptyPrompt {
|
||||
t.Fatalf("unbound registry = %#v, input = %#v", registry, input)
|
||||
if registry.Bound() || registry.Digest() != "" || registry.Count() != 0 || string(registry.CanonicalBytes()) != emptyRegistryContent {
|
||||
t.Fatalf("unbound registry = %#v", registry)
|
||||
}
|
||||
if registry.ProjectionDigest() == "" || input.Digest != registry.ProjectionDigest() || input.OriginURI != "" {
|
||||
t.Fatalf("projection digest/input = %q/%#v", registry.ProjectionDigest(), input)
|
||||
if registry.IdentityDigest() == "" {
|
||||
t.Fatal("unbound registry identity digest is empty")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveProjectsOrderedLocationsWithoutEvidence(t *testing.T) {
|
||||
func TestResolveRetainsSeparateDurableAndIdentityDigests(t *testing.T) {
|
||||
registry := resolveList(t, registryFixture())
|
||||
if !registry.Bound() || registry.Count() != 2 || registry.Digest() == "" {
|
||||
t.Fatalf("registry identity = bound %t count %d digest %q", registry.Bound(), registry.Count(), registry.Digest())
|
||||
}
|
||||
projection := string(registry.PromptInput().Content)
|
||||
if !strings.Contains(projection, `"locations":[{"id":`) || !strings.Contains(projection, `"name":"The Tavern"`) || !strings.Contains(projection, `"name":"The Tavern"},{"id":`) {
|
||||
t.Fatalf("projection ordering = %s", projection)
|
||||
}
|
||||
for _, forbidden := range []string{"source_refs", "source_id", "session-alpha"} {
|
||||
if strings.Contains(projection, forbidden) {
|
||||
t.Fatalf("projection leaked %q: %s", forbidden, projection)
|
||||
}
|
||||
}
|
||||
if registry.PromptInput().Digest != registry.ProjectionDigest() || registry.Digest() == registry.ProjectionDigest() {
|
||||
t.Fatalf("full/projection digests = %q/%q", registry.Digest(), registry.ProjectionDigest())
|
||||
if registry.IdentityDigest() == "" || registry.Digest() == registry.IdentityDigest() {
|
||||
t.Fatalf("full/identity digests = %q/%q", registry.Digest(), registry.IdentityDigest())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,12 +52,10 @@ func TestRegistryLookupUsesIDAndReturnsDefensiveCopies(t *testing.T) {
|
||||
locations[0].SourceRefs[0].SourceID = "changed"
|
||||
canonical := registry.CanonicalBytes()
|
||||
canonical[0] = '['
|
||||
input := registry.PromptInput()
|
||||
input.Content[0] = '['
|
||||
if next, ok := registry.Lookup(first.ID); !ok || next.Name != first.Name || next.SourceRefs[0].SourceID != "session-alpha" {
|
||||
t.Fatalf("registry mutated through accessor: %#v, %t", next, ok)
|
||||
}
|
||||
if registry.CanonicalBytes()[0] != '{' || registry.PromptInput().Content[0] != '{' {
|
||||
if registry.CanonicalBytes()[0] != '{' {
|
||||
t.Fatal("registry bytes mutated through accessor")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user