@@ -41,7 +41,7 @@ var _ = Describe("HaveACMHub", func() {
4141
4242 })
4343
44- Context ("when the ACM Hub exists" , func () {
44+ Context ("when the ACM Hub exists, and owned by the pattern operator " , func () {
4545 BeforeEach (func () {
4646 hub := & unstructured.Unstructured {
4747 Object : map [string ]any {
@@ -50,6 +50,9 @@ var _ = Describe("HaveACMHub", func() {
5050 "metadata" : map [string ]any {
5151 "name" : "multiclusterhub" ,
5252 "namespace" : "open-cluster-management" ,
53+ "annotations" : map [string ]any {
54+ "patterns.gitops.validatedpatterns.io/managed" : "true" ,
55+ },
5356 },
5457 },
5558 }
@@ -63,21 +66,30 @@ var _ = Describe("HaveACMHub", func() {
6366 })
6467 })
6568
66- Context ("when the ACM Hub does not exist" , func () {
69+ Context ("when the ACM Hub exists, and NOT owned by the pattern operator" , func () {
70+ BeforeEach (func () {
71+ hub := & unstructured.Unstructured {
72+ Object : map [string ]any {
73+ "apiVersion" : "operator.open-cluster-management.io/v1" ,
74+ "kind" : "MultiClusterHub" ,
75+ "metadata" : map [string ]any {
76+ "name" : "multiclusterhub" ,
77+ "namespace" : "open-cluster-management" ,
78+ },
79+ },
80+ }
81+ _ , err := dynamicClient .Resource (gvrMCH ).Namespace ("open-cluster-management" ).Create (context .Background (), hub , metav1.CreateOptions {})
82+ Expect (err ).ToNot (HaveOccurred ())
83+ })
84+
6785 It ("should return false" , func () {
6886 result := haveACMHub (patternReconciler )
6987 Expect (result ).To (BeFalse ())
7088 })
7189 })
7290
73- Context ("when there is an error listing ConfigMaps" , func () {
74- BeforeEach (func () {
75- kubeClient .PrependReactor ("list" , "configmaps" , func (testing.Action ) (handled bool , ret runtime.Object , err error ) {
76- return true , nil , fmt .Errorf ("config map error" )
77- })
78- })
79-
80- It ("should return false and log the error" , func () {
91+ Context ("when the ACM Hub does not exist" , func () {
92+ It ("should return false" , func () {
8193 result := haveACMHub (patternReconciler )
8294 Expect (result ).To (BeFalse ())
8395 })
0 commit comments