Precompute canonical paths before sorting

This commit is contained in:
2026-10-09 03:27:42 +00:00
parent 9ac65ccc08
commit d34a98d34b
11 changed files with 209 additions and 39 deletions

View File

@@ -206,6 +206,31 @@ func TestResolutionSequenceReplacementUpdatesDescendantOrigins(t *testing.T) {
}
}
func TestOrderedResolutionRecordsSortEscapedPointers(t *testing.T) {
parsedIndex, err := ParsePath("/items/0")
if err != nil {
t.Fatal(err)
}
records := map[string]*resolutionRecord{
"tilde": {path: Keys("a~b")},
"slash": {path: Keys("a/b")},
"nested": {path: Keys("a", "b")},
"index": {path: Keys("items").Index(0)},
"parsed": {path: parsedIndex},
"last": {path: Keys("z")},
}
ordered := orderedResolutionRecords(records)
want := []string{"/a/b", "/a~0b", "/a~1b", "/items/0", "/items/0", "/z"}
if len(ordered) != len(want) {
t.Fatalf("ordered records = %d, want %d", len(ordered), len(want))
}
for i, record := range ordered {
if got := record.path.String(); got != want[i] {
t.Fatalf("record[%d] path = %q, want %q", i, got, want[i])
}
}
}
func TestResolutionRejectsUnrecordedAndMismatchedMutations(t *testing.T) {
t.Parallel()