@@ -13,8 +13,6 @@ import (
1313
1414func TestHostedControlPlaneWebhook_ValidateCreate (t * testing.T ) {
1515 webhook := & hostedControlPlaneWebhook {}
16- ctx := t .Context ()
17- g := NewWithT (t )
1816
1917 tests := []struct {
2018 name string
@@ -37,7 +35,7 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
3735 Name : "test-gateway" ,
3836 Namespace : "default" ,
3937 },
40- ETCD : & ETCDComponent {
38+ ETCD : ETCDComponent {
4139 AutoGrow : true ,
4240 },
4341 },
@@ -60,9 +58,9 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
6058 Name : "test-gateway" ,
6159 Namespace : "default" ,
6260 },
63- ETCD : & ETCDComponent {
61+ ETCD : ETCDComponent {
6462 AutoGrow : false ,
65- VolumeSize : resource .MustParse ("20Gi" ),
63+ VolumeSize : ptr . To ( resource .MustParse ("20Gi" ) ),
6664 },
6765 },
6866 },
@@ -83,7 +81,7 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
8381 Name : "test-gateway" ,
8482 Namespace : "default" ,
8583 },
86- ETCD : & ETCDComponent {
84+ ETCD : ETCDComponent {
8785 AutoGrow : true ,
8886 },
8987 },
@@ -106,9 +104,9 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
106104 Name : "test-gateway" ,
107105 Namespace : "default" ,
108106 },
109- ETCD : & ETCDComponent {
107+ ETCD : ETCDComponent {
110108 AutoGrow : true ,
111- VolumeSize : resource .MustParse ("20Gi" ),
109+ VolumeSize : ptr . To ( resource .MustParse ("20Gi" ) ),
112110 },
113111 },
114112 },
@@ -130,7 +128,7 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
130128 Name : "test-gateway" ,
131129 Namespace : "default" ,
132130 },
133- ETCD : & ETCDComponent {
131+ ETCD : ETCDComponent {
134132 AutoGrow : false ,
135133 },
136134 },
@@ -143,7 +141,8 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
143141
144142 for _ , tt := range tests {
145143 t .Run (tt .name , func (t * testing.T ) {
146- _ , err := webhook .ValidateCreate (ctx , tt .hcp )
144+ g := NewWithT (t )
145+ _ , err := webhook .ValidateCreate (t .Context (), tt .hcp )
147146
148147 if tt .expectErr {
149148 g .Expect (err ).To (MatchError (ContainSubstring (tt .errMsg )))
@@ -156,8 +155,6 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
156155
157156func TestHostedControlPlaneWebhook_ValidateUpdate (t * testing.T ) {
158157 webhook := & hostedControlPlaneWebhook {}
159- ctx := t .Context ()
160- g := NewWithT (t )
161158
162159 createValidHCP := func (version string , autoGrow bool , volumeSize string ) * HostedControlPlane {
163160 hcp := & HostedControlPlane {
@@ -172,15 +169,15 @@ func TestHostedControlPlaneWebhook_ValidateUpdate(t *testing.T) {
172169 Name : "test-gateway" ,
173170 Namespace : "default" ,
174171 },
175- ETCD : & ETCDComponent {
172+ ETCD : ETCDComponent {
176173 AutoGrow : autoGrow ,
177174 },
178175 },
179176 },
180177 }
181178
182179 if volumeSize != "" {
183- hcp .Spec .ETCD .VolumeSize = resource .MustParse (volumeSize )
180+ hcp .Spec .ETCD .VolumeSize = ptr . To ( resource .MustParse (volumeSize ) )
184181 }
185182
186183 return hcp
@@ -276,7 +273,8 @@ func TestHostedControlPlaneWebhook_ValidateUpdate(t *testing.T) {
276273
277274 for _ , tt := range tests {
278275 t .Run (tt .name , func (t * testing.T ) {
279- _ , err := webhook .ValidateUpdate (ctx , tt .oldHCP , tt .newHCP )
276+ g := NewWithT (t )
277+ _ , err := webhook .ValidateUpdate (t .Context (), tt .oldHCP , tt .newHCP )
280278
281279 if tt .expectErr {
282280 g .Expect (err ).To (MatchError (ContainSubstring (tt .errMsg )))
@@ -289,7 +287,6 @@ func TestHostedControlPlaneWebhook_ValidateUpdate(t *testing.T) {
289287
290288func TestHostedControlPlaneWebhook_ValidateDelete (t * testing.T ) {
291289 webhook := & hostedControlPlaneWebhook {}
292- ctx := t .Context ()
293290 g := NewWithT (t )
294291
295292 hcp := & HostedControlPlane {
@@ -299,13 +296,12 @@ func TestHostedControlPlaneWebhook_ValidateDelete(t *testing.T) {
299296 },
300297 }
301298
302- _ , err := webhook .ValidateDelete (ctx , hcp )
299+ _ , err := webhook .ValidateDelete (t . Context () , hcp )
303300 g .Expect (err ).NotTo (HaveOccurred ())
304301}
305302
306303func TestHostedControlPlaneWebhook_CastObjectToHostedControlPlane (t * testing.T ) {
307304 webhook := & hostedControlPlaneWebhook {}
308- g := NewWithT (t )
309305
310306 tests := []struct {
311307 name string
@@ -330,6 +326,7 @@ func TestHostedControlPlaneWebhook_CastObjectToHostedControlPlane(t *testing.T)
330326
331327 for _ , tt := range tests {
332328 t .Run (tt .name , func (t * testing.T ) {
329+ g := NewWithT (t )
333330 result , err := webhook .castObjectToHostedControlPlane (tt .obj )
334331
335332 if tt .expectErr {
@@ -345,7 +342,6 @@ func TestHostedControlPlaneWebhook_CastObjectToHostedControlPlane(t *testing.T)
345342
346343func TestHostedControlPlaneWebhook_ParseVersion (t * testing.T ) {
347344 webhook := & hostedControlPlaneWebhook {}
348- g := NewWithT (t )
349345
350346 tests := []struct {
351347 name string
@@ -386,6 +382,7 @@ func TestHostedControlPlaneWebhook_ParseVersion(t *testing.T) {
386382
387383 for _ , tt := range tests {
388384 t .Run (tt .name , func (t * testing.T ) {
385+ g := NewWithT (t )
389386 hcp := & HostedControlPlane {
390387 Spec : HostedControlPlaneSpec {
391388 Version : tt .version ,
0 commit comments