The take-in blanked a package's pin in every import-form entry, the node-engine's among them though it was no mover, and nothing filled it: every composition of main.506 could not run. A module that is no mover of the take-in keeps its pins, since no step of that pipeline builds it. Tests: TestMoversOf gains the subcase "an import-form importer that is no mover keeps its pin of a package a mover publishes" (1984/AC7); I12's subcase is kept as 1984/AC8. TestASourceRevisionMovingMeshSDKNamesItAndItsImporters (integration) asserted the old blank for importer at m3's take-in, where the take-in makes importer no mover (its fingerprint does not move, noted on issue 1984 as note 24); its assertion now follows H-A-628 (1): blank where importer is a mover of that take-in, its pin kept where not. Builds: design 47 H2 H-A-628 (1) (hq cea6404c); D1 H-A-532 DMC-1; D2 H-A-547 (2)
108 lines
6.6 KiB
Go
108 lines
6.6 KiB
Go
package index
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
|
)
|
|
|
|
// A take-in's movers (design 47 H §743, A-476a as H2 H-A-520 amends it): the moved repository's modules whose fingerprint
|
|
// moved, every module with a reported import set whose fingerprint moved, and every module with none that requires a package
|
|
// of one of them (H-A-528); a module of another repository with no reported set is no mover by its fingerprint alone.
|
|
func TestMoversOf(t *testing.T) {
|
|
sdk := func(fp string) meshcatalog.CatalogEntry {
|
|
return meshcatalog.CatalogEntry{Module: "mesh-sdk", Repository: "novox/mesh-sdk", Commit: "s" + fp, Fp: fp,
|
|
Artifacts: []meshcatalog.Artifact{{Language: "go", Package: &meshcatalog.ArtifactPackage{Ecosystem: "go", Name: "git.novox.be/novox/mesh-sdk/go"}}}}
|
|
}
|
|
importer := meshcatalog.CatalogEntry{Module: "gate", Repository: "novox/mesh-catalog", Commit: "g1", Fp: "g",
|
|
Packages: map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.20"}}
|
|
// Design 47 H2 H-A-520, H-A-536, H-A-538: an importer whose import set is reported (its import form set).
|
|
reported := func(fp string) meshcatalog.CatalogEntry {
|
|
return meshcatalog.CatalogEntry{Module: "avahi", Repository: "novox/mesh-catalog", Commit: "a1", Fp: fp,
|
|
Packages: map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.20"},
|
|
Inputs: &meshcatalog.EntryInputs{From: &meshcatalog.FingerprintInputs{Imports: []string{"git.novox.be/novox/mesh-sdk/go/announce"}, ImportForm: "src2:a"}}}
|
|
}
|
|
other := func(fp string) meshcatalog.CatalogEntry {
|
|
return meshcatalog.CatalogEntry{Module: "feh", Repository: "novox/mesh-catalog", Commit: "f1", Fp: fp}
|
|
}
|
|
entries := func(es ...meshcatalog.CatalogEntry) map[string]meshcatalog.CatalogEntry {
|
|
m := map[string]meshcatalog.CatalogEntry{}
|
|
for _, e := range es {
|
|
m[e.Module] = e
|
|
}
|
|
return m
|
|
}
|
|
for _, c := range []struct {
|
|
name string
|
|
before []meshcatalog.CatalogEntry
|
|
after map[string]meshcatalog.CatalogEntry
|
|
moved []string
|
|
want []string
|
|
}{
|
|
{"a mesh-sdk commit moves mesh-sdk and its importers", []meshcatalog.CatalogEntry{sdk("1"), importer, other("f")},
|
|
entries(sdk("2"), importer, other("f")), []string{"novox/mesh-sdk"}, []string{"gate", "mesh-sdk"}},
|
|
{"a commit changing only a document names no mover", []meshcatalog.CatalogEntry{sdk("1"), importer},
|
|
entries(sdk("1"), importer), []string{"novox/mesh-sdk"}, nil},
|
|
{"a module not registered for the moved repository is no mover", []meshcatalog.CatalogEntry{sdk("1"), other("f")},
|
|
entries(sdk("1"), other("f2")), []string{"novox/mesh-sdk"}, nil},
|
|
{"a module the newest revision does not hold moves", nil,
|
|
entries(other("f")), []string{"novox/mesh-catalog"}, []string{"feh"}},
|
|
// I7/AC1, AC2: a mesh-sdk commit changing announce moves mesh-sdk, the reported importer of announce, whose fingerprint
|
|
// moved, and gate, with no reported set, by its requirement (H-A-528).
|
|
{"a reported importer whose fingerprint moved moves", []meshcatalog.CatalogEntry{sdk("1"), importer, reported("a")},
|
|
entries(sdk("2"), importer, reported("a2")), []string{"novox/mesh-sdk"}, []string{"avahi", "gate", "mesh-sdk"}},
|
|
// I7/AC3: one changing buildstep alone leaves the reported importer of announce where it was: no mover.
|
|
{"a reported importer of no changed package is no mover", []meshcatalog.CatalogEntry{sdk("1"), importer, reported("a")},
|
|
entries(sdk("2"), importer, reported("a")), []string{"novox/mesh-sdk"}, []string{"gate", "mesh-sdk"}},
|
|
{"a module with no fingerprint is no mover", nil,
|
|
entries(other("")), []string{"novox/mesh-catalog"}, nil},
|
|
} {
|
|
t.Run(c.name, func(t *testing.T) {
|
|
var got []string
|
|
for _, m := range moversOf(c.before, c.after, c.moved) {
|
|
if e := c.after[m.Module]; m.Commit != e.Commit || m.Fingerprint != e.Fp || m.Repository != e.Repository {
|
|
t.Errorf("mover %s = %+v, not its entry's commit, fingerprint and repository", m.Module, m)
|
|
}
|
|
got = append(got, m.Module)
|
|
}
|
|
if !reflect.DeepEqual(got, c.want) {
|
|
t.Errorf("movers = %v, want %v", got, c.want)
|
|
}
|
|
})
|
|
}
|
|
// I12 (design 47 H2 H-A-532 DMC-1, H-A-547 Q5): an import-form importer of a package a mover of the take-in publishes names
|
|
// no version for it in the revision's entry, so its build waits for that pipeline's publish; a version-line importer keeps
|
|
// its pin (its fingerprint takes it), and a take-in that moves no publisher touches nothing.
|
|
// 1984/AC8: the import-form importer here is a mover (its fingerprint moved), so its entry is blanked.
|
|
t.Run("an import-form importer names no version for a package a mover publishes", func(t *testing.T) {
|
|
after := entries(sdk("2"), importer, reported("a2"))
|
|
got := unpinnedByMovers(after, moversOf([]meshcatalog.CatalogEntry{sdk("1"), importer, reported("a")}, after, []string{"novox/mesh-sdk"}))
|
|
if v, named := got["avahi"].Packages["git.novox.be/novox/mesh-sdk/go"]; !named || v != "" {
|
|
t.Errorf("the import-form importer's packages = %v, want mesh-sdk/go named with no version", got["avahi"].Packages)
|
|
}
|
|
if got["gate"].Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.20" || after["avahi"].Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.20" {
|
|
t.Errorf("the version-line importer's packages = %v (the entry given %v), want both pinned as they were", got["gate"].Packages, after["avahi"].Packages)
|
|
}
|
|
still := entries(sdk("1"), reported("a"))
|
|
if got := unpinnedByMovers(still, moversOf([]meshcatalog.CatalogEntry{sdk("1"), reported("a")}, still, []string{"novox/mesh-sdk"})); got["avahi"].Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.20" {
|
|
t.Errorf("a take-in moving no publisher unpinned %v", got["avahi"].Packages)
|
|
}
|
|
})
|
|
// 1984/AC7 (design 47 H2 H-A-628 (1)): an import-form importer that is no mover of the take-in (its fingerprint did not
|
|
// move: no package it imports changed) keeps its pin of a package a mover publishes, since no step of that pipeline
|
|
// builds it and so no build waits for the publish.
|
|
t.Run("an import-form importer that is no mover keeps its pin of a package a mover publishes", func(t *testing.T) {
|
|
after := entries(sdk("2"), importer, reported("a"))
|
|
movers := moversOf([]meshcatalog.CatalogEntry{sdk("1"), importer, reported("a")}, after, []string{"novox/mesh-sdk"})
|
|
for _, m := range movers {
|
|
if m.Module == "avahi" {
|
|
t.Fatalf("movers %v hold the importer whose fingerprint did not move", movers)
|
|
}
|
|
}
|
|
if got := unpinnedByMovers(after, movers); got["avahi"].Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.20" {
|
|
t.Errorf("the import-form non-mover's packages = %v, want mesh-sdk/go pinned at v0.1.20 as it was", got["avahi"].Packages)
|
|
}
|
|
})
|
|
}
|