@@ -26,47 +26,48 @@ import (
2626 "sigs.k8s.io/controller-runtime/pkg/client"
2727 "sigs.k8s.io/controller-runtime/pkg/client/fake"
2828
29+ runtimev1 "sigs.k8s.io/cluster-api/exp/runtime/api/v1alpha1"
2930 runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
3031 runtimecatalog "sigs.k8s.io/cluster-api/internal/runtime/catalog"
3132)
3233
33- func TestIsMarked (t * testing.T ) {
34+ func TestIsPending (t * testing.T ) {
3435 tests := []struct {
3536 name string
3637 obj client.Object
3738 hook runtimecatalog.Hook
3839 want bool
3940 }{
4041 {
41- name : "should return true if the hook is marked" ,
42+ name : "should return true if the hook is marked as pending " ,
4243 obj : & corev1.ConfigMap {
4344 ObjectMeta : metav1.ObjectMeta {
4445 Name : "test-cluster" ,
4546 Namespace : "test-ns" ,
4647 Annotations : map [string ]string {
47- runtimehooksv1 .PendingHooksAnnotation : "AfterClusterUpgrade" ,
48+ runtimev1 .PendingHooksAnnotation : "AfterClusterUpgrade" ,
4849 },
4950 },
5051 },
5152 hook : runtimehooksv1 .AfterClusterUpgrade ,
5253 want : true ,
5354 },
5455 {
55- name : "should return true if the hook is marked - other hooks are marked too" ,
56+ name : "should return true if the hook is marked - other hooks are marked as pending too" ,
5657 obj : & corev1.ConfigMap {
5758 ObjectMeta : metav1.ObjectMeta {
5859 Name : "test-cluster" ,
5960 Namespace : "test-ns" ,
6061 Annotations : map [string ]string {
61- runtimehooksv1 .PendingHooksAnnotation : "AfterClusterUpgrade,AfterControlPlaneUpgrade" ,
62+ runtimev1 .PendingHooksAnnotation : "AfterClusterUpgrade,AfterControlPlaneUpgrade" ,
6263 },
6364 },
6465 },
6566 hook : runtimehooksv1 .AfterClusterUpgrade ,
6667 want : true ,
6768 },
6869 {
69- name : "should return false if the hook is not marked" ,
70+ name : "should return false if the hook is not marked as pending " ,
7071 obj : & corev1.ConfigMap {
7172 ObjectMeta : metav1.ObjectMeta {
7273 Name : "test-cluster" ,
@@ -77,13 +78,13 @@ func TestIsMarked(t *testing.T) {
7778 want : false ,
7879 },
7980 {
80- name : "should return false if the hook is not marked - other hooks are marked" ,
81+ name : "should return false if the hook is not marked - other hooks are marked as pending " ,
8182 obj : & corev1.ConfigMap {
8283 ObjectMeta : metav1.ObjectMeta {
8384 Name : "test-cluster" ,
8485 Namespace : "test-ns" ,
8586 Annotations : map [string ]string {
86- runtimehooksv1 .PendingHooksAnnotation : "AfterControlPlaneUpgrade" ,
87+ runtimev1 .PendingHooksAnnotation : "AfterControlPlaneUpgrade" ,
8788 },
8889 },
8990 },
@@ -100,14 +101,14 @@ func TestIsMarked(t *testing.T) {
100101 }
101102}
102103
103- func TestMark (t * testing.T ) {
104+ func TestMarkAsPending (t * testing.T ) {
104105 tests := []struct {
105106 name string
106107 obj client.Object
107108 hook runtimecatalog.Hook
108109 }{
109110 {
110- name : "should add the marker if not already present " ,
111+ name : "should add the marker if not already marked as pending " ,
111112 obj : & corev1.ConfigMap {
112113 ObjectMeta : metav1.ObjectMeta {
113114 Name : "test-cluster" ,
@@ -117,26 +118,26 @@ func TestMark(t *testing.T) {
117118 hook : runtimehooksv1 .AfterClusterUpgrade ,
118119 },
119120 {
120- name : "should add the marker if not already present - other hooks are present" ,
121+ name : "should add the marker if not already marked as pending - other hooks are present" ,
121122 obj : & corev1.ConfigMap {
122123 ObjectMeta : metav1.ObjectMeta {
123124 Name : "test-cluster" ,
124125 Namespace : "test-ns" ,
125126 Annotations : map [string ]string {
126- runtimehooksv1 .PendingHooksAnnotation : "AfterControlPlaneUpgrade" ,
127+ runtimev1 .PendingHooksAnnotation : "AfterControlPlaneUpgrade" ,
127128 },
128129 },
129130 },
130131 hook : runtimehooksv1 .AfterClusterUpgrade ,
131132 },
132133 {
133- name : "should pass if the marker is already present " ,
134+ name : "should pass if the marker is already marked as pending " ,
134135 obj : & corev1.ConfigMap {
135136 ObjectMeta : metav1.ObjectMeta {
136137 Name : "test-cluster" ,
137138 Namespace : "test-ns" ,
138139 Annotations : map [string ]string {
139- runtimehooksv1 .PendingHooksAnnotation : "AfterClusterUpgrade" ,
140+ runtimev1 .PendingHooksAnnotation : "AfterClusterUpgrade" ,
140141 },
141142 },
142143 },
@@ -151,12 +152,12 @@ func TestMark(t *testing.T) {
151152 ctx := context .Background ()
152153 g .Expect (MarkAsPending (ctx , fakeClient , tt .obj , tt .hook )).To (Succeed ())
153154 annotations := tt .obj .GetAnnotations ()
154- g .Expect (annotations [runtimehooksv1 .PendingHooksAnnotation ]).To (ContainSubstring (runtimecatalog .HookName (tt .hook )))
155+ g .Expect (annotations [runtimev1 .PendingHooksAnnotation ]).To (ContainSubstring (runtimecatalog .HookName (tt .hook )))
155156 })
156157 }
157158}
158159
159- func TestUnmark (t * testing.T ) {
160+ func TestMarkAsDone (t * testing.T ) {
160161 tests := []struct {
161162 name string
162163 obj client.Object
@@ -179,7 +180,7 @@ func TestUnmark(t *testing.T) {
179180 Name : "test-cluster" ,
180181 Namespace : "test-ns" ,
181182 Annotations : map [string ]string {
182- runtimehooksv1 .PendingHooksAnnotation : "AfterClusterUpgrade" ,
183+ runtimev1 .PendingHooksAnnotation : "AfterClusterUpgrade" ,
183184 },
184185 },
185186 },
@@ -192,7 +193,7 @@ func TestUnmark(t *testing.T) {
192193 Name : "test-cluster" ,
193194 Namespace : "test-ns" ,
194195 Annotations : map [string ]string {
195- runtimehooksv1 .PendingHooksAnnotation : "AfterClusterUpgrade,AfterControlPlaneUpgrade" ,
196+ runtimev1 .PendingHooksAnnotation : "AfterClusterUpgrade,AfterControlPlaneUpgrade" ,
196197 },
197198 },
198199 },
@@ -207,7 +208,7 @@ func TestUnmark(t *testing.T) {
207208 ctx := context .Background ()
208209 g .Expect (MarkAsDone (ctx , fakeClient , tt .obj , tt .hook )).To (Succeed ())
209210 annotations := tt .obj .GetAnnotations ()
210- g .Expect (annotations [runtimehooksv1 .PendingHooksAnnotation ]).NotTo (ContainSubstring (runtimecatalog .HookName (tt .hook )))
211+ g .Expect (annotations [runtimev1 .PendingHooksAnnotation ]).NotTo (ContainSubstring (runtimecatalog .HookName (tt .hook )))
211212 })
212213 }
213214}
0 commit comments