Index mapping assembly for composition and overlays
This commit is contained in:
@@ -116,6 +116,31 @@ func TestComposeDocumentsReportsAllClaimantsAtExactLocations(t *testing.T) {
|
||||
assertCompositionConflict(t, diagnostics, "/group", []string{"source-1", "source-2", "source-3"})
|
||||
}
|
||||
|
||||
func TestComposeDocumentsKeepsFirstConflictAndAppendedEntryOrder(t *testing.T) {
|
||||
first := parseCompositionDocument(t, "source-1", "catalog:\n first: 1\n shared: one\n later: one\n")
|
||||
second := parseCompositionDocument(t, "source-2", "catalog:\n second: 2\n shared: two\n later: two\n")
|
||||
third := parseCompositionDocument(t, "source-3", "catalog:\n third: 3\n shared: three\n")
|
||||
_, diagnostics := composeDocuments(first, second, third)
|
||||
assertCompositionConflict(t, diagnostics, "/catalog/shared", []string{"source-1", "source-2", "source-3"})
|
||||
|
||||
composed, diagnostics := composeDocuments(
|
||||
parseCompositionDocument(t, "source-1", "catalog:\n first: 1\n"),
|
||||
parseCompositionDocument(t, "source-2", "catalog:\n second: 2\n"),
|
||||
parseCompositionDocument(t, "source-3", "catalog:\n third: 3\n"),
|
||||
)
|
||||
if len(diagnostics) != 0 {
|
||||
t.Fatalf("composeDocuments() diagnostics = %#v", diagnostics)
|
||||
}
|
||||
entries := composed.root.Mapping[0].Value.Mapping
|
||||
got := make([]string, len(entries))
|
||||
for index, entry := range entries {
|
||||
got[index] = entry.Key
|
||||
}
|
||||
if want := []string{"first", "second", "third"}; !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("catalog keys = %#v, want %#v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestComposeDocumentsTreatsEmptyMappingsAsChildlessContributions(t *testing.T) {
|
||||
empty, diagnostics := composeDocuments(
|
||||
parseCompositionDocument(t, "source-1", "{}\n"),
|
||||
|
||||
Reference in New Issue
Block a user