Precompute canonical paths before sorting
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user