55 lines
2.5 KiB
Go
55 lines
2.5 KiB
Go
package view
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
|
)
|
|
|
|
// I5 (issue 1851): from R4e the indexer writes the new form alone, and a module's fingerprint is built by the builder's key
|
|
// of it; the page shows the indexer's fp2 against that key's state, or the reason it has none.
|
|
|
|
const fp2A = "src2:3333333333333333333333333333333333333333333333333333333333333333"
|
|
|
|
func builderKey(t *testing.T, module, fp2 string, b builds.BuilderBuild) Entry {
|
|
t.Helper()
|
|
key, err := builds.BuilderBuildKey(module, fp2)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
data, err := builds.EncodeBuilderBuild(b)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return Entry{Bucket: builds.BuilderBuildsBucket, Key: key, Value: data, At: t0}
|
|
}
|
|
|
|
func TestAFingerprintOfTheNewFormIsShownAgainstItsBuilderKey(t *testing.T) { // I5
|
|
m := New()
|
|
manifest := strings.Repeat("a", 64)
|
|
d := "sha256:" + strings.Repeat("2", 64)
|
|
fill(m,
|
|
modEntry(t, "a", meshcatalog.ModulesByModuleValue{Fp2: fp2A, Manifest: manifest, Repository: "novox/mesh-delivery", Commit: hA}),
|
|
builderKey(t, "a", fp2A, builds.BuilderBuild{State: builds.BuildDone, By: "shanks.mesh-delivery-builder", Manifest: manifest,
|
|
Artifacts: []builds.BuiltArtifact{{Name: "program", Kind: "bundle", Digest: d, Reference: "artifact-store://a/program/blobs/" + d}}}),
|
|
modEntry(t, "f", meshcatalog.ModulesByModuleValue{Fp2: fp2A, Manifest: manifest, Repository: "novox/mesh-delivery", Commit: hA}),
|
|
builderKey(t, "f", fp2A, builds.BuilderBuild{State: builds.BuildFailed, By: "shanks.mesh-delivery-builder", Manifest: manifest, Error: "not stored: program: 507"}),
|
|
modEntry(t, "n", meshcatalog.ModulesByModuleValue{Fp2: fp2A, Manifest: manifest, Repository: "novox/mesh-delivery", Commit: hA}),
|
|
modEntry(t, "r", meshcatalog.ModulesByModuleValue{None2: "toolchain not yet reported", Repository: "novox/mesh-delivery", Commit: hA}))
|
|
s := m.Snapshot()
|
|
if r := fpRow(t, s, "a"); r.State != FPBuilt || r.Indexer != fp2A {
|
|
t.Errorf("a = %+v, want built with the indexer's fp2", r)
|
|
}
|
|
if r := fpRow(t, s, "f"); r.State != FPBuildFailed || !strings.Contains(r.Reason, "not stored") {
|
|
t.Errorf("f = %+v, want build failed with its error", r)
|
|
}
|
|
if r := fpRow(t, s, "n"); r.State != FPNoKey || r.Indexer != fp2A {
|
|
t.Errorf("n = %+v, want no key", r)
|
|
}
|
|
if r := fpRow(t, s, "r"); r.State != FPNone || r.Reason != "toolchain not yet reported" {
|
|
t.Errorf("r = %+v, want none with the new form's reason", r)
|
|
}
|
|
}
|