Files
mesh-delivery/modules/mesh-delivery-view/internal/view/fingerprints_newform_test.go
T
jschoubben 39db267630 D1 (builder): the builder names its own module and buckets from its credential's module
Its states' buckets, its finding observer, its build log entries and its step asks' asker take the credential's module (tools: the module the runtime serves them as) instead of constants of its name; builds.StateBucket/BuildsBucket replace the Bucket constants. The readers of the builds bucket (checker, view, grants) still name the builder: the next D1 subtask finds it by the seat mesh-builds.

Builds: design 47 G A-296, §428

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 22:34:08 +01:00

56 lines
2.6 KiB
Go

package view
import (
"strings"
"testing"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate"
)
// 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.BuildsBucket(builds.BuilderModule), Key: key, Value: data, At: t0}
}
func TestAFingerprintOfTheNewFormIsShownAgainstItsBuilderKey(t *testing.T) { // I5
m := New(viewstate.ViewModule)
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)
}
}