reference: add test-coverage for digested references

Trying to overwrite a digest with another digest is not allowed, and
cannot be forced.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-11-14 17:15:40 +01:00
parent f71439d527
commit f52e935f36
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -161,6 +161,10 @@ func TestAddDeleteGet(t *testing.T) {
if err = store.AddDigest(ref5.(reference.Canonical), testImageID2, false); err != nil {
t.Fatalf("error redundantly adding to store: %v", err)
}
err = store.AddDigest(ref5.(reference.Canonical), testImageID3, false)
assert.Check(t, is.ErrorType(err, errdefs.IsConflict), "overwriting a digest with a different digest should fail")
err = store.AddDigest(ref5.(reference.Canonical), testImageID3, true)
assert.Check(t, is.ErrorType(err, errdefs.IsConflict), "overwriting a digest cannot be forced")
// Attempt to overwrite with force == false
err = store.AddTag(ref4, testImageID3, false)