Name, before the switch, which modules it moves: the held build's digests against the builder's done key, images and packages said as what cannot be compared (issue 1851, A13)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
sdkdelivery "git.novox.be/novox/mesh-sdk/go/delivery"
|
||||
"github.com/novox/mesh-controller/internal/builderkeys"
|
||||
"github.com/novox/mesh-controller/internal/inventory"
|
||||
)
|
||||
|
||||
// A13 (ADR 0453 §6; issue 1851): the switch's list names every module moved or unmoved and why: the held build's
|
||||
// digests against the done key's; an image or a package as what cannot be compared; a key not done as not known.
|
||||
func TestTheSwitchsListNamesWhatMovesAndWhy(t *testing.T) {
|
||||
const d1, d2 = "sha256:" + "1111111111111111111111111111111111111111111111111111111111111111",
|
||||
"sha256:" + "2222222222222222222222222222222222222222222222222222222222222222"
|
||||
trunk := sdkdelivery.Module{FP2: "src2:" + strings.Repeat("a", 64)}
|
||||
done := func(arts ...sdkdelivery.BuiltArtifact) builderkeys.Key {
|
||||
return builderkeys.Key{Found: true, Fingerprint: trunk.FP2, Build: sdkdelivery.BuilderBuild{State: sdkdelivery.BuildDone,
|
||||
Artifacts: arts}}
|
||||
}
|
||||
held := []inventory.Artifact{{Name: "tools", Kind: "bundle", Reference: "artifact-store://x/tools/blobs/" + d1}}
|
||||
for _, c := range []struct {
|
||||
what string
|
||||
held []inventory.Artifact
|
||||
trunk sdkdelivery.Module
|
||||
key builderkeys.Key
|
||||
verdict string
|
||||
says string
|
||||
}{
|
||||
{"the same digest", held, trunk, done(sdkdelivery.BuiltArtifact{Name: "tools", Kind: "bundle", Digest: d1}), switchUnmoved, "no move"},
|
||||
{"another digest", held, trunk, done(sdkdelivery.BuiltArtifact{Name: "tools", Kind: "bundle", Digest: d2}), switchMoves, "tools 111111111111 -> 222222222222"},
|
||||
{"an image", []inventory.Artifact{{Name: "img", Kind: "image", Reference: "artifact-store://x/img@" + d1}}, trunk,
|
||||
done(sdkdelivery.BuiltArtifact{Name: "img", Kind: "image", Digest: d2}), switchUncompared, "img is an image"},
|
||||
{"a package", []inventory.Artifact{{Name: "lib", Kind: "package", Reference: "@novox/lib@1.2.0"}}, trunk,
|
||||
done(sdkdelivery.BuiltArtifact{Name: "lib", Kind: "package", Digest: d2}), switchUncompared, "published by its version"},
|
||||
{"a key building", held, trunk, builderkeys.Key{Module: "x", Fingerprint: trunk.FP2, Found: true,
|
||||
Build: sdkdelivery.BuilderBuild{State: sdkdelivery.BuildBuilding}}, switchUnknown, "is building"},
|
||||
{"no fingerprint", held, sdkdelivery.Module{None2: "no lock"}, builderkeys.Key{}, switchUnknown, "no lock"},
|
||||
} {
|
||||
l := switchLineOf("x", c.held, c.trunk, c.key)
|
||||
if l.Verdict != c.verdict || !strings.Contains(l.Why, c.says) {
|
||||
t.Errorf("%s: %+v, want %s saying %q", c.what, l, c.verdict, c.says)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user