Split the unit level from the integration level in cmd, builder, link, catalogue, inventory; cheap fixtures for the archive-entry bound, the registry waits and the catalogue copy (issue 895)

This commit is contained in:
2026-10-17 21:32:23 +02:00
parent aac4bae5a4
commit 66dc501fc4
438 changed files with 22014 additions and 19825 deletions
@@ -0,0 +1,44 @@
//go:build integration
package builder
import (
"context"
"strings"
"testing"
)
func fingerprintOf(t *testing.T, manifest, tree string, mirrored string) string {
t.Helper()
r, workspace := aRepository(t, manifest, map[string]string{"modules/bus/Dockerfile": "ARG BASE\nFROM ${BASE}"})
r.contents["modules/bus/module.json"] = manifest
r.tree = tree
m := &mirroring{recorded: r, at: mirrored}
got, err := Build(context.Background(), r.run, m, "https://forge.invalid/catalogue.git", "modules/bus", "", workspace,
nil, Npmrc{}, GitCredential{}, nil)
if err != nil {
t.Fatal(err)
}
return got.Source
}
func TestASourceFingerprintNamesWhatABuildWasMadeFrom(t *testing.T) {
one := fingerprintOf(t, anImage, "aaaa", "registry-a:5000")
if !strings.HasPrefix(one, sourcePrefix) {
t.Fatalf("no fingerprint: %q", one)
}
// The same tree and base, the base copied to another registry address: one source.
if again := fingerprintOf(t, anImage, "aaaa", "registry-b:5000"); again != one {
t.Fatalf("one source has two fingerprints: %s %s", one, again)
}
// The module's tree changed: another source.
if changed := fingerprintOf(t, anImage, "bbbb", "registry-a:5000"); changed == one {
t.Fatal("a changed tree kept its fingerprint")
}
// The base moved: another source.
moved := strings.Replace(anImage, "1111111111111111111111111111111111111111111111111111111111111111",
"2222222222222222222222222222222222222222222222222222222222222222", 1)
if changed := fingerprintOf(t, moved, "aaaa", "registry-a:5000"); changed == one {
t.Fatal("a moved base kept its fingerprint")
}
}