@@ -99,16 +99,8 @@ func TestPurgeUntaggedOnly(t *testing.T) {
9999 assert := assert .New (t )
100100 mockClient := & mocks.AcrCLIClientInterface {}
101101
102- // Mock GetRepositories to return multiple repos
103- repos := []string {"repo1" , "repo2" , "repo3" }
104- reposResult := & acr.Repositories {
105- Response : autorest.Response {
106- Response : & http.Response {
107- StatusCode : 200 ,
108- },
109- },
110- Names : & repos ,
111- }
102+ // We won't test GetRepositories here since the purge function is called
103+ // with already-created tagFilters. Instead test that all repos are processed.
112104
113105 emptyManifestsResult := & acr.Manifests {
114106 Response : autorest.Response {
@@ -121,10 +113,8 @@ func TestPurgeUntaggedOnly(t *testing.T) {
121113 ManifestsAttributes : & []acr.ManifestAttributesBase {},
122114 }
123115
124- // Mock repository listing
125- mockClient .On ("GetRepositories" , mock .Anything , "" , int32 (100 )).Return (reposResult , nil ).Once ()
126-
127116 // Mock manifest calls for each repo (no untagged manifests in this test)
117+ repos := []string {"repo1" , "repo2" , "repo3" }
128118 for _ , repo := range repos {
129119 mockClient .On ("GetAcrManifests" , mock .Anything , repo , "" , "" ).Return (emptyManifestsResult , nil ).Once ()
130120 }
@@ -196,7 +186,7 @@ func TestPurgeUntaggedOnly(t *testing.T) {
196186 // Mock manifest calls for specific repo
197187 mockClient .On ("GetAcrManifests" , mock .Anything , "specific-repo" , "" , "" ).Return (manifestsResult , nil ).Once ()
198188 mockClient .On ("GetAcrManifests" , mock .Anything , "specific-repo" , "" , manifestDigest ).Return (emptyManifestsResult , nil ).Once ()
199- mockClient . On ( " GetManifest" , mock . Anything , "specific-repo" , manifestDigest ). Return ([] byte ( `{"schemaVersion": 2}` ), nil ). Once ()
189+ // Note: GetManifest is not called for untagged manifests
200190 localDeletedResponse := & autorest.Response {
201191 Response : & http.Response {
202192 StatusCode : 202 ,
@@ -265,7 +255,7 @@ func TestPurgeUntaggedOnly(t *testing.T) {
265255 // Mock manifest calls but NO delete calls in dry-run
266256 mockClient .On ("GetAcrManifests" , mock .Anything , testRepo , "" , "" ).Return (manifestsResult , nil ).Once ()
267257 mockClient .On ("GetAcrManifests" , mock .Anything , testRepo , "" , manifestDigest ).Return (emptyManifestsResult , nil ).Once ()
268- mockClient . On ( " GetManifest" , mock . Anything , testRepo , manifestDigest ). Return ([] byte ( `{"schemaVersion": 2}` ), nil ). Once ()
258+ // Note: GetManifest is not called for untagged manifests
269259 // No DeleteManifest call expected in dry-run mode
270260
271261 deletedTagsCount , deletedManifestsCount , err := purge (
@@ -340,8 +330,7 @@ func TestPurgeUntaggedOnly(t *testing.T) {
340330 // Without --include-locked, only unlocked manifest should be deleted
341331 mockClient .On ("GetAcrManifests" , mock .Anything , testRepo , "" , "" ).Return (manifestsResult , nil ).Once ()
342332 mockClient .On ("GetAcrManifests" , mock .Anything , testRepo , "" , unlockedDigest ).Return (emptyManifestsResult , nil ).Once ()
343- mockClient .On ("GetManifest" , mock .Anything , testRepo , lockedDigest ).Return ([]byte (`{"schemaVersion": 2}` ), nil ).Once ()
344- mockClient .On ("GetManifest" , mock .Anything , testRepo , unlockedDigest ).Return ([]byte (`{"schemaVersion": 2}` ), nil ).Once ()
333+ // Note: GetManifest is not called for untagged manifests
345334 localDeletedResponse := & autorest.Response {
346335 Response : & http.Response {
347336 StatusCode : 202 ,
@@ -412,9 +401,15 @@ func TestPurgeUntaggedOnly(t *testing.T) {
412401 // With --include-locked, locked manifest should be unlocked and deleted
413402 mockClient .On ("GetAcrManifests" , mock .Anything , testRepo , "" , "" ).Return (manifestsResult , nil ).Once ()
414403 mockClient .On ("GetAcrManifests" , mock .Anything , testRepo , "" , lockedDigest ).Return (emptyManifestsResult , nil ).Once ()
415- mockClient . On ( " GetManifest" , mock . Anything , testRepo , lockedDigest ). Return ([] byte ( `{"schemaVersion": 2}` ), nil ). Once ()
404+ // Note: GetManifest is not called for untagged manifests
416405 // Expect unlock and delete for locked manifest
417- mockClient .On ("UpdateAcrManifestAttributes" , mock .Anything , testRepo , lockedDigest , mock .Anything ).Return (nil ).Once ()
406+ // UpdateAcrManifestAttributes returns an interface, not just nil
407+ updateResponse := & autorest.Response {
408+ Response : & http.Response {
409+ StatusCode : 200 ,
410+ },
411+ }
412+ mockClient .On ("UpdateAcrManifestAttributes" , mock .Anything , testRepo , lockedDigest , mock .Anything ).Return (updateResponse , nil ).Once ()
418413 localDeletedResponse := & autorest.Response {
419414 Response : & http.Response {
420415 StatusCode : 202 ,
0 commit comments