Cut metadata history over to shared model
This commit is contained in:
@@ -160,7 +160,19 @@ func TestMetadataQueriesReturnDetachedRecords(t *testing.T) {
|
||||
|
||||
path := Keys("service", "workers")
|
||||
builder := newHistoryBuilder()
|
||||
builder.observeDocument(parseDocumentForDecode(t, "service: {workers: null}\n"), historyPhaseBaseline)
|
||||
root := parseDocumentForDecode(t, "service: {workers: null}\n")
|
||||
builder.observeBaseline(root)
|
||||
payload := builder.nextPayload(historyPhaseResolution)
|
||||
attribution := builder.addAttribution(
|
||||
Origin{Layer: LayerResolution, Locations: []Location{{SourceID: "source-1"}}},
|
||||
[]string{"bounded worker count"}, []Path{Keys("limits")},
|
||||
)
|
||||
builder.addObservation(historyObservation{
|
||||
path: path, phase: historyPhaseResolution, payload: payload,
|
||||
reportedPath: path, role: historyRoleOperation,
|
||||
beforePresent: true, afterPresent: true,
|
||||
attributionRef: attribution,
|
||||
})
|
||||
metadata := Metadata{
|
||||
effectivePaths: map[string]Path{path.String(): path},
|
||||
historyModel: builder.freeze(),
|
||||
@@ -173,15 +185,6 @@ func TestMetadataQueriesReturnDetachedRecords(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
history: map[string][]Change{
|
||||
path.String(): {{
|
||||
Path: path,
|
||||
Origin: Origin{Layer: LayerResolution, Locations: []Location{{SourceID: "source-1"}}},
|
||||
Previous: []Origin{{Layer: LayerDefault, Locations: []Location{{SourceID: "default"}}}},
|
||||
Reasons: []string{"bounded worker count"},
|
||||
Dependencies: []Path{Keys("limits")},
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
||||
info, ok := metadata.Lookup(path)
|
||||
@@ -195,13 +198,17 @@ func TestMetadataQueriesReturnDetachedRecords(t *testing.T) {
|
||||
}
|
||||
|
||||
history := metadata.History(path)
|
||||
history[0].Reasons[0] = "mutated"
|
||||
history[0].Previous[0].Locations[0].SourceID = "mutated"
|
||||
history[0].Dependencies[0].segments[0].key = "mutated"
|
||||
last := len(history) - 1
|
||||
history[last].Origin.Locations[0].SourceID = "mutated"
|
||||
history[last].Reasons[0] = "mutated"
|
||||
history[last].Previous[0].Layer = "mutated"
|
||||
history[last].Dependencies[0].segments[0].key = "mutated"
|
||||
againHistory := metadata.History(path)
|
||||
if againHistory[0].Reasons[0] != "bounded worker count" ||
|
||||
againHistory[0].Previous[0].Locations[0].SourceID != "default" ||
|
||||
againHistory[0].Dependencies[0].String() != "/limits" {
|
||||
lastAgain := len(againHistory) - 1
|
||||
if againHistory[lastAgain].Origin.Locations[0].SourceID != "source-1" ||
|
||||
againHistory[lastAgain].Reasons[0] != "bounded worker count" ||
|
||||
againHistory[lastAgain].Previous[0].Layer != LayerDefault ||
|
||||
againHistory[lastAgain].Dependencies[0].String() != "/limits" {
|
||||
t.Fatal("History returned aliased nested records")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user