Swaps three import paths for mesh-sdk's go/catalogue, go/overlay and go/validate (the same packages, copied from this repository at 6c2a8d62) and lets gofmt order the groups. The six swap commits compile together once the pin commit (go.mod, modules.txt) is on the branch; each alone does not, because a file on the SDK's types cannot call one still on the old package.
53 lines
2.1 KiB
Go
53 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
"github.com/novox/mesh-controller/internal/inventory"
|
|
)
|
|
|
|
// A merge that rebuilds a base rebuilds what stands on it, through every layer, and nothing else
|
|
// (novox/hq issue 186): the runtime image moving means every module built on it moves too, and a
|
|
// module built on one of those moves as well.
|
|
func TestAMergeOfABaseTakesWhatStandsOnItAlong(t *testing.T) {
|
|
entry := func(name string) inventory.Entry {
|
|
return inventory.Entry{Manifest: catalogue.Manifest{Module: name}}
|
|
}
|
|
entries := []inventory.Entry{entry("mesh-tools"), entry("shop"), entry("shop-plugin"), entry("postgres"), entry("unrelated")}
|
|
against := map[string][]string{
|
|
"shop": {catalogue.ArtifactStoreScheme + "mesh-tools/runtime@sha256:a"},
|
|
"shop-plugin": {catalogue.ArtifactStoreScheme + "shop/runtime@sha256:b"},
|
|
"postgres": {catalogue.ArtifactStoreScheme + "mesh-tools/runtime@sha256:a"},
|
|
"unrelated": {catalogue.ArtifactStoreScheme + "alpine/base@sha256:c"},
|
|
}
|
|
got := dependentsOf([]inventory.Entry{entry("mesh-tools")}, entries, against)
|
|
var names []string
|
|
for _, e := range got {
|
|
names = append(names, e.Manifest.Module)
|
|
}
|
|
want := map[string]bool{"shop": true, "shop-plugin": true, "postgres": true}
|
|
if len(names) != len(want) {
|
|
t.Fatalf("rebuilt %v; wanted exactly the three that stand on the runtime, directly or through shop", names)
|
|
}
|
|
for _, n := range names {
|
|
if !want[n] {
|
|
t.Fatalf("%s was rebuilt and stands on nothing that moved (%v)", n, names)
|
|
}
|
|
}
|
|
// The dependents come in base order when the merge orders them: the runtime, then shop, then
|
|
// the plugin that stands on shop.
|
|
ordered := orderByBases(append([]inventory.Entry{entry("mesh-tools")}, got...), against)
|
|
pos := map[string]int{}
|
|
for i, e := range ordered {
|
|
pos[e.Manifest.Module] = i
|
|
}
|
|
if !(pos["mesh-tools"] < pos["shop"] && pos["shop"] < pos["shop-plugin"]) {
|
|
t.Fatalf("not in base order: %v", ordered)
|
|
}
|
|
// Nothing moved: nothing follows.
|
|
if more := dependentsOf(nil, entries, against); len(more) != 0 {
|
|
t.Fatalf("with nothing moved, %d module(s) were rebuilt", len(more))
|
|
}
|
|
}
|