One source now has several catalog revisions, so a publish naming branch and source alone does not say which pipeline published it. The seat mesh-builds' package-published gains an optional revision (seatgen regenerated). The version reserved for a build keeps the catalog revision number: from the picture's half when the picture starts the build (the same revision its source comes from), from the step ask's run when the ask reaches the build first. Its package-published says it. A reservation from before the field says none. Builds: design 47 H H-A-218, H-A-220
45 lines
2.0 KiB
Go
45 lines
2.0 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
|
"mesh-delivery-builder/internal/build"
|
|
)
|
|
|
|
// TestTheManifestOfAnEntryIsReadByItsDigest: the builder reads a manifest from the entry that holds it, by the entry's manifest
|
|
// digest (design 47 G §348), and an entry with no manifest keeps none.
|
|
func TestTheManifestOfAnEntryIsReadByItsDigest(t *testing.T) {
|
|
m := &entryManifests{}
|
|
e := meshcatalog.CatalogEntry{Module: "netcheck", ManifestDigest: "sha256:aa", Manifest: map[string]any{"module": "netcheck", "version": "1"}}
|
|
if err := m.keep(e); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if mf, err := m.Manifest(context.Background(), "aa"); err != nil || mf.Module != "netcheck" {
|
|
t.Errorf("Manifest(aa) = %+v, %v", mf, err)
|
|
}
|
|
if _, err := m.Manifest(context.Background(), "bb"); err == nil {
|
|
t.Error("Manifest of a digest no entry holds: want an error")
|
|
}
|
|
if err := m.keep(meshcatalog.CatalogEntry{Module: "bare"}); err != nil || len(m.byFp) != 1 {
|
|
t.Errorf("an entry with no manifest kept one: %v, %v", err, m.byFp)
|
|
}
|
|
}
|
|
|
|
// H-A-220: an entry the picture takes in has the source revision and the catalog revision number of the half its view holds,
|
|
// one revision for both; a view holding no half names neither.
|
|
func TestAnEntryThePictureTakesInNamesItsHalfsRevision(t *testing.T) {
|
|
o := build.Origin{Branch: "main", First: true}
|
|
got := pictureOrigin(o, func() (meshcatalogclient.Half, bool) {
|
|
return meshcatalogclient.Half{Revision: meshcatalog.CatalogRevision{Revision: 47, Source: 45}}, true
|
|
})
|
|
if got != (build.Origin{Branch: "main", First: true, Source: 45, Revision: 47}) {
|
|
t.Errorf("origin = %+v, want source 45 at revision 47", got)
|
|
}
|
|
if got := pictureOrigin(o, func() (meshcatalogclient.Half, bool) { return meshcatalogclient.Half{}, false }); got != o {
|
|
t.Errorf("origin with no half = %+v, want %+v", got, o)
|
|
}
|
|
}
|