@@ -1038,6 +1038,43 @@ func TestGetSourceNamespacesWithWildCardNamespace(t *testing.T) {
1038
1038
assert .Contains (t , sourceNamespaces , "test-namespace-1" )
1039
1039
assert .Contains (t , sourceNamespaces , "test-namespace-2" )
1040
1040
}
1041
+ func TestGetSourceNamespacesWithRegExpNamespace (t * testing.T ) {
1042
+ a := makeTestArgoCD ()
1043
+ a .Spec = argoproj.ArgoCDSpec {
1044
+ SourceNamespaces : []string {
1045
+ "/^test.*test$/" ,
1046
+ },
1047
+ }
1048
+ ns1 := v1.Namespace {
1049
+ ObjectMeta : metav1.ObjectMeta {
1050
+ Name : "testtest" ,
1051
+ },
1052
+ }
1053
+ ns2 := v1.Namespace {
1054
+ ObjectMeta : metav1.ObjectMeta {
1055
+ Name : "test123test" ,
1056
+ },
1057
+ }
1058
+ ns3 := v1.Namespace {
1059
+ ObjectMeta : metav1.ObjectMeta {
1060
+ Name : "test-abc-test" ,
1061
+ },
1062
+ }
1063
+
1064
+ resObjs := []client.Object {a , & ns1 , & ns2 , & ns3 }
1065
+ subresObjs := []client.Object {a }
1066
+ runtimeObjs := []runtime.Object {}
1067
+ sch := makeTestReconcilerScheme (argoproj .AddToScheme )
1068
+ cl := makeTestReconcilerClient (sch , resObjs , subresObjs , runtimeObjs )
1069
+ r := makeTestReconciler (cl , sch )
1070
+
1071
+ sourceNamespaces , err := r .getSourceNamespaces (a )
1072
+ assert .NoError (t , err )
1073
+ assert .Equal (t , 3 , len (sourceNamespaces ))
1074
+ assert .Contains (t , sourceNamespaces , "testtest" )
1075
+ assert .Contains (t , sourceNamespaces , "test123test" )
1076
+ assert .Contains (t , sourceNamespaces , "test-abc-test" )
1077
+ }
1041
1078
1042
1079
func TestGenerateRandomString (t * testing.T ) {
1043
1080
0 commit comments