issue 1025: a context naming the module's own repository is its own build source (ADR 0420 §4)
This commit is contained in:
@@ -1267,6 +1267,8 @@ func graphOfFacts(f snapshot.Facts) ([]inventory.Entry, map[string][]inventory.R
|
||||
read[mod.Name] = append(read[mod.Name], inventory.ReadRepository{Own: true, Paths: s.Paths})
|
||||
}
|
||||
}
|
||||
// A context naming the module's own repository is its own build source (novox/hq ADR 0420 §4).
|
||||
read[mod.Name] = inventory.OwnRepositoryAsOwn(read[mod.Name], mod.Repository)
|
||||
}
|
||||
var edges []inventory.Edge
|
||||
for _, e := range f.Edges {
|
||||
|
||||
@@ -680,3 +680,35 @@ func TestAPlanSaysWhyEachModuleIsInIt(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// **A context naming the module's own repository is the module's own build source** (novox/hq ADR 0420 §4,
|
||||
// issue 1025). A module registered from the controller's repository whose image compiles cmd/x through a
|
||||
// context naming that same repository is moved by a change to the program, and by none outside its closure.
|
||||
func TestAContextNamingTheModulesOwnRepositoryIsItsOwnBuildSource(t *testing.T) {
|
||||
const controllerRepo = "http://forge.internal:20000/novox/mesh-controller.git"
|
||||
entries := []inventory.Entry{fromRepo("mover", controllerRepo, "modules/mover")}
|
||||
said := []inventory.ReadRepository{
|
||||
{Repository: "novox/mesh-controller", Ref: "main", Paths: []string{"go.mod", "cmd/x/", "internal/y/"}},
|
||||
{Own: true, Paths: []string{"modules/mover/module.json"}},
|
||||
}
|
||||
read := map[string][]inventory.ReadRepository{"mover": inventory.OwnRepositoryAsOwn(said, controllerRepo)}
|
||||
for _, c := range []struct {
|
||||
what string
|
||||
paths []string
|
||||
want string
|
||||
}{
|
||||
{"the program its image compiles", []string{"cmd/x/main.go"}, "mover"},
|
||||
{"a package the program imports", []string{"internal/y/y.go"}, "mover"},
|
||||
{"its own manifest", []string{"modules/mover/module.json"}, "mover"},
|
||||
{"a file outside its closure", []string{"cmd/other/main.go"}, ""},
|
||||
} {
|
||||
if _, got := planMerge(t, "mesh-controller", c.paths, entries, read, nil); got != c.want {
|
||||
t.Errorf("%s: planned %q, wanted %q", c.what, got, c.want)
|
||||
}
|
||||
}
|
||||
// A context of another repository stays a context read, and a context of this one that said no paths too.
|
||||
other := []inventory.ReadRepository{{Repository: "novox/mesh-catalog", Paths: []string{"a/"}}, {Repository: "novox/mesh-controller"}}
|
||||
if got := inventory.OwnRepositoryAsOwn(other, controllerRepo); len(got) != 2 || got[0].Own || got[1].Own {
|
||||
t.Errorf("a context that is not this repository's with paths became its own: %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user