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:
@@ -14,20 +14,6 @@ const anImage = `{"module":"bus","version":"1",
|
||||
"artifacts":[{"name":"server","kind":"image","from":"Dockerfile"}]},
|
||||
"resources":[{"id":"svc","type":"container","name":"bus","artifact":"server"}]}`
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// mirroring is a store that copies a vendor's image into the mesh's registry, at an address a test says.
|
||||
type mirroring struct {
|
||||
*recorded
|
||||
@@ -39,27 +25,6 @@ func (m *mirroring) MirrorImage(_ context.Context, from, repository string) (str
|
||||
return m.at + "/" + repository + "@" + digest, nil
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
func TestABuildTheRegistryDecidesHasNoFingerprint(t *testing.T) {
|
||||
s := newSourceInputs("app")
|
||||
s.tree = "aaaa"
|
||||
|
||||
Reference in New Issue
Block a user