A stub keeps its items and their templates, so a held module still contributes to other modules' collections; it drops only the templates for its own files (issue 1126)
mesh/delivery merged: source.main moved to novox/mesh-sdk@d4c61ee8ffd0
mesh/delivery-group group fix/1126-seed-oldbuild merged: every member is merged
mesh/check pass 76f7c4d2238f on d747c1128e42 | unit 3018 run, 270 kept, 36 skipped | integration 3039 run, 302 kept, 29 skipped | over bound: unit (sl…
mesh/delivery merged: source.main moved to novox/mesh-sdk@d4c61ee8ffd0
mesh/delivery-group group fix/1126-seed-oldbuild merged: every member is merged
mesh/check pass 76f7c4d2238f on d747c1128e42 | unit 3018 run, 270 kept, 36 skipped | integration 3039 run, 302 kept, 29 skipped | over bound: unit (sl…
This commit is contained in:
@@ -318,10 +318,15 @@ func Stub(m catalogue.Manifest) catalogue.Manifest {
|
|||||||
m.OwnsPaths = catalogue.DeclaredPaths(m)
|
m.OwnsPaths = catalogue.DeclaredPaths(m)
|
||||||
}
|
}
|
||||||
m.Build = nil
|
m.Build = nil
|
||||||
// Nor is anything of its own handed or collected: the templates and items its build kept fill resources and items a
|
// Nor is a template its build kept for its own files handed: a stub carries none of them (issue 1126: novox's node
|
||||||
// stub does not have (issue 1126: novox's node refused "postgres: its build kept a template for consumers, which it
|
// refused "postgres: its build kept a template for consumers, which it does not declare" with postgres held). Its
|
||||||
// does not declare" with postgres held).
|
// items stay, and the templates they render through: a held module's contributions to other modules' collections
|
||||||
m.Handed, m.Items = nil, nil
|
// (seat contributions, shell blocks, seat data) still reach their collectors.
|
||||||
|
if m.Handed != nil {
|
||||||
|
h := *m.Handed
|
||||||
|
h.Templates = nil
|
||||||
|
m.Handed = &h
|
||||||
|
}
|
||||||
var dirs []map[string]any
|
var dirs []map[string]any
|
||||||
for _, r := range m.Resources {
|
for _, r := range m.Resources {
|
||||||
if r["type"] == "directory" {
|
if r["type"] == "directory" {
|
||||||
|
|||||||
@@ -294,13 +294,30 @@ func answerNamesEveryRefusalAndLeavesAnOldBuildToTheNode(t *testing.T) {
|
|||||||
if got, want := catalogue.DeclaredPaths(compose.Carried(f1, "f1-circuits", &f1runs)), catalogue.DeclaredPaths(f1); !reflect.DeepEqual(got, want) {
|
if got, want := catalogue.DeclaredPaths(compose.Carried(f1, "f1-circuits", &f1runs)), catalogue.DeclaredPaths(f1); !reflect.DeepEqual(got, want) {
|
||||||
t.Errorf("f1-circuits carried owns %v, want what the controller composes from its manifest, %v", got, want)
|
t.Errorf("f1-circuits carried owns %v, want what the controller composes from its manifest, %v", got, want)
|
||||||
}
|
}
|
||||||
// Issue 1126: a held module hands and collects nothing of its own, so a template its build kept for a file it no
|
// Issue 1126: a held module hands no template its build kept for a file it no longer carries (novox's node:
|
||||||
// longer carries refuses nothing (novox's node: "postgres: its build kept a template for consumers").
|
// "postgres: its build kept a template for consumers"), but keeps its items and their templates, so what it
|
||||||
|
// contributes to other modules' collections still reaches them.
|
||||||
|
for _, row := range []struct {
|
||||||
|
name string
|
||||||
|
handed *catalogue.Handed
|
||||||
|
items []catalogue.Item
|
||||||
|
}{
|
||||||
|
{"templates and items", &catalogue.Handed{Templates: map[string]string{"consumers": "files/consumers.json"},
|
||||||
|
Items: map[string]string{"routes": "files/routes.tmpl"}}, []catalogue.Item{{Collection: "routes", Content: "x"}}},
|
||||||
|
{"items alone", nil, []catalogue.Item{{Collection: "routes", Content: "x"}}},
|
||||||
|
} {
|
||||||
kept := f1
|
kept := f1
|
||||||
kept.Handed = &catalogue.Handed{Templates: map[string]string{"consumers": "files/consumers.json"}}
|
kept.Handed, kept.Items = row.handed, row.items
|
||||||
kept.Items = []catalogue.Item{{Collection: "routes", Content: "x"}}
|
st := compose.Stub(kept)
|
||||||
if st := compose.Stub(kept); st.Handed != nil || st.Items != nil {
|
if st.Handed != nil && st.Handed.Templates != nil {
|
||||||
t.Errorf("a stub hands %+v and collects %+v", st.Handed, st.Items)
|
t.Errorf("%s: a stub hands templates %v", row.name, st.Handed.Templates)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(st.Items, row.items) {
|
||||||
|
t.Errorf("%s: a stub collects %+v, want its items %+v", row.name, st.Items, row.items)
|
||||||
|
}
|
||||||
|
if row.handed != nil && (st.Handed == nil || !reflect.DeepEqual(st.Handed.Items, row.handed.Items) || row.handed.Templates == nil) {
|
||||||
|
t.Errorf("%s: a stub hands item templates %+v, want %v and its manifest untouched", row.name, st.Handed, row.handed.Items)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var k1, k2 any
|
var k1, k2 any
|
||||||
_ = json.Unmarshal(keptComposed, &k1)
|
_ = json.Unmarshal(keptComposed, &k1)
|
||||||
|
|||||||
Reference in New Issue
Block a user