From 9d1be18ae0d909bddbdb00033bd0608c62fab5cd Mon Sep 17 00:00:00 2001 From: "Kyle M. Tarplee" Date: Thu, 21 Sep 2023 08:56:47 -0400 Subject: [PATCH] added a unit test for clone() Signed-off-by: Kyle M. Tarplee --- registry/remote/repository_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/registry/remote/repository_test.go b/registry/remote/repository_test.go index 3e3ee61a..b6772cbd 100644 --- a/registry/remote/repository_test.go +++ b/registry/remote/repository_test.go @@ -7447,3 +7447,24 @@ func TestRepository_do(t *testing.T) { t.Errorf("Repository.do() = %v, want %v", gotWarnings, wantWarnings) } } + +func TestRepository_clone(t *testing.T) { + repo, err := NewRepository("localhost:1234/repo/image") + if err != nil { + t.Fatalf("invalid repository: %v", err) + } + + crepo := repo.clone() + + if repo.Reference != crepo.Reference { + t.Fatal("references should be the same") + } + + if !reflect.DeepEqual(&repo.referrersPingLock, &crepo.referrersPingLock) { + t.Fatal("referrersPingLock should be different") + } + + if !reflect.DeepEqual(&repo.referrersMergePool, &crepo.referrersMergePool) { + t.Fatal("referrersMergePool should be different") + } +}