@@ -734,11 +734,21 @@ func TestCollectTagFilters(t *testing.T) {
734
734
mockClient .AssertExpectations (t )
735
735
})
736
736
737
- t .Run ("SingleRepo " , func (t * testing.T ) {
737
+ t .Run ("SingleRepoWithRegex " , func (t * testing.T ) {
738
738
assert := assert .New (t )
739
739
mockClient := & mocks.BaseClientAPI {}
740
740
mockClient .On ("GetRepositories" , mock .Anything , "" , mock .Anything ).Return (ManyRepositoriesResult , nil ).Once ()
741
741
mockClient .On ("GetRepositories" , mock .Anything , mock .Anything , mock .Anything ).Return (NoRepositoriesResult , nil ).Once ()
742
+ filters , err := common .CollectTagFilters (testCtx , []string {testRepo + ".?:.*" }, mockClient , 60 )
743
+ assert .Equal (1 , len (filters ), "Number of found should be one" )
744
+ assert .Equal (".*" , filters [testRepo ], "Filter for test repo should be .*" )
745
+ assert .Equal (nil , err , "Error should be nil" )
746
+ mockClient .AssertExpectations (t )
747
+ })
748
+
749
+ t .Run ("SingleRepoWithoutRegex" , func (t * testing.T ) {
750
+ assert := assert .New (t )
751
+ mockClient := & mocks.BaseClientAPI {}
742
752
filters , err := common .CollectTagFilters (testCtx , []string {testRepo + ":.*" }, mockClient , 60 )
743
753
assert .Equal (1 , len (filters ), "Number of found should be one" )
744
754
assert .Equal (".*" , filters [testRepo ], "Filter for test repo should be .*" )
@@ -764,7 +774,7 @@ func TestCollectTagFilters(t *testing.T) {
764
774
mockClient := & mocks.BaseClientAPI {}
765
775
mockClient .On ("GetRepositories" , mock .Anything , "" , mock .Anything ).Return (ManyRepositoriesResult , nil ).Once ()
766
776
mockClient .On ("GetRepositories" , mock .Anything , mock .Anything , mock .Anything ).Return (NoRepositoriesResult , nil ).Once ()
767
- filters , err := common .CollectTagFilters (testCtx , []string {"ba:.*" }, mockClient , 60 )
777
+ filters , err := common .CollectTagFilters (testCtx , []string {"ba? :.*" }, mockClient , 60 )
768
778
assert .Equal (0 , len (filters ), "Number of found repos should be zero" )
769
779
assert .Equal (nil , err , "Error should be nil" )
770
780
mockClient .AssertExpectations (t )
@@ -775,7 +785,7 @@ func TestCollectTagFilters(t *testing.T) {
775
785
mockClient := & mocks.BaseClientAPI {}
776
786
mockClient .On ("GetRepositories" , mock .Anything , "" , mock .Anything ).Return (ManyRepositoriesResult , nil ).Once ()
777
787
mockClient .On ("GetRepositories" , mock .Anything , mock .Anything , mock .Anything ).Return (NoRepositoriesResult , nil ).Once ()
778
- filters , err := common .CollectTagFilters (testCtx , []string {"foo/bar:.*" }, mockClient , 60 )
788
+ filters , err := common .CollectTagFilters (testCtx , []string {"foo/bar? :.*" }, mockClient , 60 )
779
789
assert .Equal (1 , len (filters ), "Number of found repos should be one" )
780
790
assert .Equal (nil , err , "Error should be nil" )
781
791
mockClient .AssertExpectations (t )
@@ -786,7 +796,7 @@ func TestCollectTagFilters(t *testing.T) {
786
796
mockClient := & mocks.BaseClientAPI {}
787
797
mockClient .On ("GetRepositories" , mock .Anything , "" , mock .Anything ).Return (ManyRepositoriesResult , nil ).Once ()
788
798
mockClient .On ("GetRepositories" , mock .Anything , mock .Anything , mock .Anything ).Return (NoRepositoriesResult , nil ).Once ()
789
- filters , err := common .CollectTagFilters (testCtx , []string {"foo/bar:(?:.*)" }, mockClient , 60 )
799
+ filters , err := common .CollectTagFilters (testCtx , []string {"foo/bar? :(?:.*)" }, mockClient , 60 )
790
800
assert .Equal (1 , len (filters ), "Number of found repos should be one" )
791
801
assert .Equal (nil , err , "Error should be nil" )
792
802
mockClient .AssertExpectations (t )
@@ -840,7 +850,7 @@ func TestCollectTagFilters(t *testing.T) {
840
850
assert := assert .New (t )
841
851
mockClient := & mocks.BaseClientAPI {}
842
852
mockClient .On ("GetRepositories" , mock .Anything , "" , mock .Anything ).Return (NoRepositoriesResult , nil ).Once ()
843
- filters , err := common .CollectTagFilters (testCtx , []string {testRepo + ":.*" }, mockClient , 60 )
853
+ filters , err := common .CollectTagFilters (testCtx , []string {testRepo + "? :.*" }, mockClient , 60 )
844
854
assert .Equal (0 , len (filters ), "Number of found repos should be zero" )
845
855
assert .Equal (nil , err , "Error should be nil" )
846
856
mockClient .AssertExpectations (t )
@@ -849,8 +859,6 @@ func TestCollectTagFilters(t *testing.T) {
849
859
t .Run ("EmptyRepoRegex" , func (t * testing.T ) {
850
860
assert := assert .New (t )
851
861
mockClient := & mocks.BaseClientAPI {}
852
- mockClient .On ("GetRepositories" , mock .Anything , "" , mock .Anything ).Return (ManyRepositoriesResult , nil ).Once ()
853
- mockClient .On ("GetRepositories" , mock .Anything , mock .Anything , mock .Anything ).Return (NoRepositoriesResult , nil ).Once ()
854
862
_ , err := common .CollectTagFilters (testCtx , []string {":.*" }, mockClient , 60 )
855
863
assert .NotEqual (nil , err , "Error should not be nil" )
856
864
mockClient .AssertExpectations (t )
@@ -859,8 +867,6 @@ func TestCollectTagFilters(t *testing.T) {
859
867
t .Run ("EmptyTagRegex" , func (t * testing.T ) {
860
868
assert := assert .New (t )
861
869
mockClient := & mocks.BaseClientAPI {}
862
- mockClient .On ("GetRepositories" , mock .Anything , "" , mock .Anything ).Return (ManyRepositoriesResult , nil ).Once ()
863
- mockClient .On ("GetRepositories" , mock .Anything , mock .Anything , mock .Anything ).Return (NoRepositoriesResult , nil ).Once ()
864
870
_ , err := common .CollectTagFilters (testCtx , []string {testRepo + ".*:" }, mockClient , 60 )
865
871
assert .NotEqual (nil , err , "Error should not be nil" )
866
872
mockClient .AssertExpectations (t )
0 commit comments