Precompute canonical paths before sorting
This commit is contained in:
@@ -271,6 +271,43 @@ func TestOverrideEqualReplacementStillAppearsInHistory(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAffectedOverrideOriginsSortEscapedPointers(t *testing.T) {
|
||||
existingInput := parseCompositionDocument(t, "source-1", `values:
|
||||
z: old
|
||||
a/b: slash
|
||||
a~b: tilde
|
||||
nested: {x: old}
|
||||
`)
|
||||
existing, diagnostics := composeDocuments(existingInput)
|
||||
if len(diagnostics) != 0 {
|
||||
t.Fatal(diagnostics)
|
||||
}
|
||||
incoming := parseCompositionDocument(t, "source-2", `values:
|
||||
z: new
|
||||
a/b: new
|
||||
a~b: new
|
||||
nested: {x: new}
|
||||
`)
|
||||
existingValues, ok := documentAtPath(existing.root, Keys("values"))
|
||||
if !ok {
|
||||
t.Fatal("existing values mapping is missing")
|
||||
}
|
||||
incomingValues, ok := documentAtPath(incoming, Keys("values"))
|
||||
if !ok {
|
||||
t.Fatal("incoming values mapping is missing")
|
||||
}
|
||||
displaced := affectedOverrideOrigins(existingValues, incomingValues, existing.origins, Keys("values"), &mappingIndex{})
|
||||
want := []string{"/values", "/values/a~0b", "/values/a~1b", "/values/nested", "/values/nested/x", "/values/z"}
|
||||
if len(displaced) != len(want) {
|
||||
t.Fatalf("displaced definitions = %d, want %d", len(displaced), len(want))
|
||||
}
|
||||
for i, definition := range displaced {
|
||||
if got := definition.path.String(); got != want[i] {
|
||||
t.Fatalf("displaced[%d] path = %q, want %q", i, got, want[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOverrideAggregateLimitsFailBeforeApplication(t *testing.T) {
|
||||
base, diagnostics := composeDocuments(&document.Node{Kind: document.Mapping})
|
||||
if len(diagnostics) != 0 {
|
||||
|
||||
Reference in New Issue
Block a user