Pass effective destinations through import traversal
This commit is contained in:
@@ -39,6 +39,34 @@ func TestNormalizeDestinationUsesLiteralMappingKeys(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppendDestinationCopiesLiteralSegments(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
parent := Keys("collection", "entry")
|
||||
relative := Keys("a/b", "0", "~")
|
||||
combined := appendDestination(parent, relative)
|
||||
if got, want := combined.String(), "/collection/entry/a~1b/0/~0"; got != want {
|
||||
t.Fatalf("combined destination = %q, want %q", got, want)
|
||||
}
|
||||
if len(combined.segments) != 5 {
|
||||
t.Fatalf("combined segments = %#v", combined.segments)
|
||||
}
|
||||
for index, segment := range combined.segments {
|
||||
if segment.kind != pathSegmentKey {
|
||||
t.Errorf("segment %d kind = %v, want mapping key", index, segment.kind)
|
||||
}
|
||||
}
|
||||
|
||||
combined.segments[0].key = "changed parent"
|
||||
combined.segments[2].key = "changed relative"
|
||||
if got := parent.String(); got != "/collection/entry" {
|
||||
t.Fatalf("combined path shares parent segment storage: %q", got)
|
||||
}
|
||||
if got := relative.String(); got != "/a~1b/0/~0" {
|
||||
t.Fatalf("combined path shares relative segment storage: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeDestinationRejectsIndicesAndReservedKeys(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user