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

@@ -357,6 +357,21 @@ func TestCompareDocumentTreesTracksSemanticChanges(t *testing.T) {
}
}
func TestCompareConfigurationValuesSortEscapedPointers(t *testing.T) {
before := parseCompositionDocument(t, "before", `values: {z: old, 'a/b': old, 'a~b': old, nested: {x: old}}`)
after := parseCompositionDocument(t, "after", `values: {z: new, 'a/b': new, 'a~b': new, nested: {x: new}}`)
deltas := compareConfigurationValues(before, after)
want := []string{"/values/a~0b", "/values/a~1b", "/values/nested/x", "/values/z"}
if len(deltas) != len(want) {
t.Fatalf("deltas = %#v", deltas)
}
for i, delta := range deltas {
if got := delta.path.String(); got != want[i] {
t.Fatalf("delta[%d] path = %q, want %q", i, got, want[i])
}
}
}
func mustSchemaFor[T any](t *testing.T) *schemaDescriptor {
t.Helper()
schema, issue := testBuildSchema(reflect.TypeFor[T]())