package builder import ( "context" "strings" "testing" ) // A build's source fingerprint (novox/hq issue 280): what it was made from, so a rebuild of an unchanged // source is one build however the image digest it made differs. const anImage = `{"module":"bus","version":"1", "build":{"on":[{"arg":"BASE","image":"vendor/server@sha256:` + "1111111111111111111111111111111111111111111111111111111111111111" + `"}], "artifacts":[{"name":"server","kind":"image","from":"Dockerfile"}]}, "resources":[{"id":"svc","type":"container","name":"bus","artifact":"server"}]}` // 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 at string } func (m *mirroring) MirrorImage(_ context.Context, from, repository string) (string, error) { _, digest, _ := strings.Cut(from, "@") return m.at + "/" + repository + "@" + digest, nil } func TestABuildTheRegistryDecidesHasNoFingerprint(t *testing.T) { s := newSourceInputs("app") s.tree = "aaaa" if s.fingerprint() == "" { t.Fatal("a pinned source has no fingerprint") } s.notPinned("it resolves packages from the mesh's registry at build time") if got := s.fingerprint(); got != "" { t.Fatalf("a build the registry decides has a fingerprint: %s", got) } if (&sourceInputs{module: "app"}).fingerprint() != "" { t.Fatal("a build whose tree was not named has a fingerprint") } }