@@ -28,6 +28,7 @@ import (
2828 "github.com/stretchr/testify/assert"
2929 "k8s.io/client-go/kubernetes"
3030 testclient "k8s.io/client-go/kubernetes/fake"
31+ "k8s.io/utils/pointer"
3132 "net/http"
3233 "net/http/httptest"
3334 "strings"
@@ -269,7 +270,7 @@ func TestPatchCluster(t *testing.T) {
269270 tcs := []struct {
270271 name string
271272 cluster * registryv1.Cluster
272- clusterPatch ClusterPatch
273+ clusterSpec ClusterSpec
273274 expectedStatus int
274275 expectedBody string
275276 }{
@@ -285,11 +286,11 @@ func TestPatchCluster(t *testing.T) {
285286 Tags : map [string ]string {"onboarding" : "on" , "scaling" : "off" },
286287 },
287288 },
288- clusterPatch : ClusterPatch {
289- Status : "inactive" ,
289+ clusterSpec : ClusterSpec {
290+ Status : pointer . String ( "inactive" ) ,
290291 },
291292 expectedStatus : http .StatusBadRequest ,
292- expectedBody : `{"errors":{"body":"Key: 'ClusterPatch .Status' Error:Field validation for 'Status' failed on the 'oneof' tag"}}` ,
293+ expectedBody : `{"errors":{"body":"Key: 'ClusterSpec .Status' Error:Field validation for 'Status' failed on the 'oneof' tag"}}` ,
293294 },
294295 {
295296 name : "invalid phase (case sensitive)" ,
@@ -303,12 +304,12 @@ func TestPatchCluster(t *testing.T) {
303304 Tags : map [string ]string {"onboarding" : "on" , "scaling" : "off" },
304305 },
305306 },
306- clusterPatch : ClusterPatch {
307- Status : "Inactive" ,
308- Phase : "upgrading" ,
307+ clusterSpec : ClusterSpec {
308+ Status : pointer . String ( "Inactive" ) ,
309+ Phase : pointer . String ( "upgrading" ) ,
309310 },
310311 expectedStatus : http .StatusBadRequest ,
311- expectedBody : `{"errors":{"body":"Key: 'ClusterPatch .Phase' Error:Field validation for 'Phase' failed on the 'oneof' tag"}}` ,
312+ expectedBody : `{"errors":{"body":"Key: 'ClusterSpec .Phase' Error:Field validation for 'Phase' failed on the 'oneof' tag"}}` ,
312313 },
313314 {
314315 name : "invalid value for `scaling` tag" ,
@@ -322,9 +323,9 @@ func TestPatchCluster(t *testing.T) {
322323 Tags : map [string ]string {"onboarding" : "on" , "scaling" : "off" },
323324 },
324325 },
325- clusterPatch : ClusterPatch {
326- Status : "Inactive" ,
327- Tags : map [string ]string {
326+ clusterSpec : ClusterSpec {
327+ Status : pointer . String ( "Inactive" ) ,
328+ Tags : & map [string ]string {
328329 "onboarding" : "off" ,
329330 "scaling" : "enabled" ,
330331 },
@@ -344,9 +345,9 @@ func TestPatchCluster(t *testing.T) {
344345 Tags : map [string ]string {"onboarding" : "on" , "scaling" : "off" },
345346 },
346347 },
347- clusterPatch : ClusterPatch {
348- Status : "Inactive" ,
349- Tags : map [string ]string {
348+ clusterSpec : ClusterSpec {
349+ Status : pointer . String ( "Inactive" ) ,
350+ Tags : & map [string ]string {
350351 "onboarding" : "false" ,
351352 },
352353 },
@@ -365,9 +366,9 @@ func TestPatchCluster(t *testing.T) {
365366 Tags : map [string ]string {"onboarding" : "on" , "scaling" : "off" },
366367 },
367368 },
368- clusterPatch : ClusterPatch {
369- Status : "Inactive" ,
370- Tags : map [string ]string {
369+ clusterSpec : ClusterSpec {
370+ Status : pointer . String ( "Inactive" ) ,
371+ Tags : & map [string ]string {
371372 "some-made-up-tag" : "on" ,
372373 },
373374 },
@@ -381,7 +382,7 @@ func TestPatchCluster(t *testing.T) {
381382 r := web .NewRouter ()
382383 h := NewHandler (appConfig , db , m , & TestClientProvider {})
383384
384- patch , _ := json .Marshal (tc .clusterPatch )
385+ patch , _ := json .Marshal (tc .clusterSpec )
385386 body := strings .NewReader (string (patch ))
386387 req := httptest .NewRequest (echo .PATCH , "/api/v2/clusters/:name" , body )
387388 req .Header .Set (echo .HeaderContentType , echo .MIMEApplicationJSON )
0 commit comments