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