@@ -511,7 +511,7 @@ func TestIncludeLockedFlagAnnotate(t *testing.T) {
511
511
assert := assert .New (t )
512
512
mockClient := & mocks.AcrCLIClientInterface {}
513
513
mockOrasClient := & mocks.ORASClientInterface {}
514
-
514
+
515
515
// Create a locked tag result
516
516
lockedTagResult := & acr.RepositoryTagsType {
517
517
Response : autorest.Response {
@@ -528,27 +528,27 @@ func TestIncludeLockedFlagAnnotate(t *testing.T) {
528
528
Digest : & digest ,
529
529
}},
530
530
}
531
-
531
+
532
532
mockClient .On ("GetAcrTags" , mock .Anything , testRepo , "timedesc" , "" ).Return (lockedTagResult , nil ).Once ()
533
533
mockOrasClient .On ("DiscoverLifecycleAnnotation" , mock .Anything , fmt .Sprintf ("%s/%s:%s" , testLoginURL , testRepo , tagName ), testArtifactType ).Return (false , nil ).Once ()
534
-
534
+
535
535
regex , _ := common .BuildRegexFilter (".*" , 60 )
536
- manifests , _ , skipped , err := getManifestsToAnnotate (testCtx , mockClient , mockOrasClient , testLoginURL , testRepo ,
536
+ manifests , _ , skipped , err := getManifestsToAnnotate (testCtx , mockClient , mockOrasClient , testLoginURL , testRepo ,
537
537
regex , "" , testArtifactType , false , true ) // include-locked = true
538
-
538
+
539
539
assert .Equal (1 , len (manifests ), "Should include locked tag when include-locked is true" )
540
540
assert .Equal (0 , skipped , "Should not skip any tags" )
541
541
assert .Equal (nil , err , "Error should be nil" )
542
542
mockClient .AssertExpectations (t )
543
543
mockOrasClient .AssertExpectations (t )
544
544
})
545
-
545
+
546
546
// Test that without include-locked flag, locked tags are filtered out
547
547
t .Run ("NoIncludeLockedSkipsLockedTag" , func (t * testing.T ) {
548
548
assert := assert .New (t )
549
549
mockClient := & mocks.AcrCLIClientInterface {}
550
550
mockOrasClient := & mocks.ORASClientInterface {}
551
-
551
+
552
552
// Create a locked tag result
553
553
lockedTagResult := & acr.RepositoryTagsType {
554
554
Response : autorest.Response {
@@ -565,26 +565,26 @@ func TestIncludeLockedFlagAnnotate(t *testing.T) {
565
565
Digest : & digest ,
566
566
}},
567
567
}
568
-
568
+
569
569
mockClient .On ("GetAcrTags" , mock .Anything , testRepo , "timedesc" , "" ).Return (lockedTagResult , nil ).Once ()
570
-
570
+
571
571
regex , _ := common .BuildRegexFilter (".*" , 60 )
572
- manifests , _ , skipped , err := getManifestsToAnnotate (testCtx , mockClient , mockOrasClient , testLoginURL , testRepo ,
572
+ manifests , _ , skipped , err := getManifestsToAnnotate (testCtx , mockClient , mockOrasClient , testLoginURL , testRepo ,
573
573
regex , "" , testArtifactType , false , false ) // include-locked = false
574
-
574
+
575
575
assert .Equal (0 , len (manifests ), "Should not include locked tag when include-locked is false" )
576
576
assert .Equal (1 , skipped , "Should skip locked tags" )
577
577
assert .Equal (nil , err , "Error should be nil" )
578
578
mockClient .AssertExpectations (t )
579
579
mockOrasClient .AssertExpectations (t )
580
580
})
581
-
581
+
582
582
// Test that with include-locked flag, locked untagged manifests are included
583
583
t .Run ("IncludeLockedIncludesLockedManifest" , func (t * testing.T ) {
584
584
assert := assert .New (t )
585
585
mockClient := & mocks.AcrCLIClientInterface {}
586
586
mockOrasClient := & mocks.ORASClientInterface {}
587
-
587
+
588
588
// Create a locked manifest without tags
589
589
lockedManifest := & acr.Manifests {
590
590
Registry : & testLoginURL ,
@@ -597,25 +597,25 @@ func TestIncludeLockedFlagAnnotate(t *testing.T) {
597
597
Tags : nil , // No tags - untagged manifest
598
598
}},
599
599
}
600
-
600
+
601
601
mockClient .On ("GetAcrManifests" , mock .Anything , testRepo , "" , "" ).Return (lockedManifest , nil ).Once ()
602
602
mockClient .On ("GetAcrManifests" , mock .Anything , testRepo , "" , digest ).Return (EmptyListManifestsResult , nil ).Once ()
603
-
603
+
604
604
mockOrasClient .On ("Annotate" , mock .Anything , fmt .Sprintf ("%s/%s@%s" , testLoginURL , testRepo , digest ), testArtifactType , annotationMap ).Return (nil ).Once ()
605
-
605
+
606
606
annotatedManifests , err := annotateUntaggedManifests (testCtx , mockClient , mockOrasClient , defaultPoolSize , testLoginURL , testRepo , testArtifactType , testAnnotations [:], false , true )
607
607
assert .Equal (1 , annotatedManifests , "Should annotate locked manifest when include-locked is true" )
608
608
assert .Equal (nil , err , "Error should be nil" )
609
609
mockClient .AssertExpectations (t )
610
610
mockOrasClient .AssertExpectations (t )
611
611
})
612
-
612
+
613
613
// Test dry run with include-locked shows locked manifests
614
614
t .Run ("DryRunWithIncludeLockedShowsLockedManifests" , func (t * testing.T ) {
615
615
assert := assert .New (t )
616
616
mockClient := & mocks.AcrCLIClientInterface {}
617
617
mockOrasClient := & mocks.ORASClientInterface {}
618
-
618
+
619
619
// Create a locked manifest without tags
620
620
lockedManifest := & acr.Manifests {
621
621
Registry : & testLoginURL ,
@@ -628,10 +628,10 @@ func TestIncludeLockedFlagAnnotate(t *testing.T) {
628
628
Tags : nil , // No tags - untagged manifest
629
629
}},
630
630
}
631
-
631
+
632
632
mockClient .On ("GetAcrManifests" , mock .Anything , testRepo , "" , "" ).Return (lockedManifest , nil ).Once ()
633
633
mockClient .On ("GetAcrManifests" , mock .Anything , testRepo , "" , digest ).Return (EmptyListManifestsResult , nil ).Once ()
634
-
634
+
635
635
annotatedManifests , err := annotateUntaggedManifests (testCtx , mockClient , mockOrasClient , defaultPoolSize , testLoginURL , testRepo , testArtifactType , testAnnotations [:], true , true )
636
636
assert .Equal (1 , annotatedManifests , "Should count locked manifest in dry run when include-locked is true" )
637
637
assert .Equal (nil , err , "Error should be nil" )
@@ -851,6 +851,6 @@ var (
851
851
"vnd.microsoft.artifact.lifecycle.end-of-life.date" : "2024-03-21" ,
852
852
}
853
853
// Variables for testing --include-locked flag
854
- writeDisabledBool = false
854
+ writeDisabledBool = false
855
855
lastUpdateTimeTest = time .Now ().Add (- 15 * time .Minute ).UTC ().Format (time .RFC3339Nano )
856
856
)
0 commit comments