@@ -157,7 +157,7 @@ func TestGetKubernetesClusters(t *testing.T) {
157157 srv , svc := setupTestServerAndService (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
158158 assert .Equal (t , http .MethodGet , r .Method )
159159 assert .Equal (t , fmt .Sprintf ("/%s/kubernetes" , client .APIVersion ), r .URL .Path )
160- fmt .Fprintf (w , "[%s]" , exampleClusterResponse )
160+ _ , _ = fmt .Fprintf (w , "[%s]" , exampleClusterResponse )
161161 }))
162162 defer srv .Close ()
163163 res , err := svc .GetKubernetesClusters (context .Background (), & request.GetKubernetesClustersRequest {})
@@ -197,7 +197,7 @@ func TestGetKubernetesClusterDetails(t *testing.T) {
197197 srv , svc := setupTestServerAndService (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
198198 assert .Equal (t , http .MethodGet , r .Method )
199199 assert .Equal (t , fmt .Sprintf ("/%s/kubernetes/_UUID_" , client .APIVersion ), r .URL .Path )
200- fmt .Fprint (w , exampleClusterResponse )
200+ _ , _ = fmt .Fprint (w , exampleClusterResponse )
201201 }))
202202 defer srv .Close ()
203203 res , err := svc .GetKubernetesCluster (context .Background (), & request.GetKubernetesClusterRequest {UUID : "_UUID_" })
@@ -216,7 +216,7 @@ func TestCreateKubernetesCluster(t *testing.T) {
216216 srv , svc := setupTestServerAndService (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
217217 // CreateKubernetesCluster method first makes a request to /network/:uuid to check network CIDR
218218 if r .Method == http .MethodGet && r .URL .Path == fmt .Sprintf ("/%s/network/03e4970d-7791-4b80-a892-682ae0faf46b" , client .APIVersion ) {
219- fmt .Fprint (w , exampleNetworkResponse )
219+ _ , _ = fmt .Fprint (w , exampleNetworkResponse )
220220 return
221221 }
222222
@@ -225,7 +225,7 @@ func TestCreateKubernetesCluster(t *testing.T) {
225225 err := json .NewDecoder (r .Body ).Decode (& payload )
226226 assert .NoError (t , err )
227227
228- fmt .Fprint (w , exampleClusterResponse )
228+ _ , _ = fmt .Fprint (w , exampleClusterResponse )
229229 return
230230 }
231231
@@ -307,7 +307,7 @@ func TestGetKubernetesNodeGroups(t *testing.T) {
307307 srv , svc := setupTestServerAndService (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
308308 assert .Equal (t , http .MethodGet , r .Method )
309309 assert .Equal (t , fmt .Sprintf ("/%s/kubernetes/_UUID_/node-groups" , client .APIVersion ), r .URL .Path )
310- fmt .Fprintf (w , "[%s]" , exampleNodeGroupResponse )
310+ _ , _ = fmt .Fprintf (w , "[%s]" , exampleNodeGroupResponse )
311311 }))
312312 defer srv .Close ()
313313
@@ -324,7 +324,7 @@ func TestGetKubernetesNodeGroup(t *testing.T) {
324324 srv , svc := setupTestServerAndService (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
325325 assert .Equal (t , http .MethodGet , r .Method )
326326 assert .Equal (t , fmt .Sprintf ("/%s/kubernetes/_UUID_/node-groups/_NAME_" , client .APIVersion ), r .URL .Path )
327- fmt .Fprint (w , exampleNodeGroupResponse )
327+ _ , _ = fmt .Fprint (w , exampleNodeGroupResponse )
328328 }))
329329 defer srv .Close ()
330330
@@ -342,7 +342,7 @@ func TestGetKubernetesNodeGroupDetails(t *testing.T) {
342342 srv , svc := setupTestServerAndService (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
343343 assert .Equal (t , http .MethodGet , r .Method )
344344 assert .Equal (t , fmt .Sprintf ("/%s/kubernetes/_UUID_/node-groups/_NAME_" , client .APIVersion ), r .URL .Path )
345- fmt .Fprint (w , exampleNodeGroupDetailsResponse )
345+ _ , _ = fmt .Fprint (w , exampleNodeGroupDetailsResponse )
346346 }))
347347 defer srv .Close ()
348348
@@ -368,7 +368,7 @@ func TestCreateKubernetesNodeGroup(t *testing.T) {
368368 err := json .NewDecoder (r .Body ).Decode (& payload )
369369 assert .NoError (t , err )
370370
371- fmt .Fprint (w , exampleNodeGroupResponse )
371+ _ , _ = fmt .Fprint (w , exampleNodeGroupResponse )
372372 }))
373373 defer srv .Close ()
374374
@@ -421,7 +421,7 @@ func TestModifyKubernetesNodeGroup(t *testing.T) {
421421 err := json .NewDecoder (r .Body ).Decode (& payload )
422422 assert .NoError (t , err )
423423
424- fmt .Fprint (w , exampleNodeGroupResponse )
424+ _ , _ = fmt .Fprint (w , exampleNodeGroupResponse )
425425 }))
426426 defer srv .Close ()
427427
@@ -440,7 +440,7 @@ func TestDeleteKubernetesNodeGroup(t *testing.T) {
440440 srv , svc := setupTestServerAndService (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
441441 assert .Equal (t , http .MethodDelete , r .Method )
442442 assert .Equal (t , fmt .Sprintf ("/%s/kubernetes/_UUID_/node-groups/_NAME_" , client .APIVersion ), r .URL .Path )
443- fmt .Fprint (w , exampleNodeGroupResponse )
443+ _ , _ = fmt .Fprint (w , exampleNodeGroupResponse )
444444 }))
445445 defer srv .Close ()
446446
@@ -480,7 +480,7 @@ func TestWaitForKubernetesClusterState(t *testing.T) {
480480 requestsMade ++
481481
482482 if requestsCounter >= 2 {
483- fmt .Fprint (w , `
483+ _ , _ = fmt .Fprint (w , `
484484 {
485485 "name":"test-name",
486486 "network":"03e4970d-7791-4b80-a892-682ae0faf46b",
@@ -493,7 +493,7 @@ func TestWaitForKubernetesClusterState(t *testing.T) {
493493 ` )
494494 } else {
495495 requestsCounter ++
496- fmt .Fprint (w , `
496+ _ , _ = fmt .Fprint (w , `
497497 {
498498 "name":"test-name",
499499 "network":"03e4970d-7791-4b80-a892-682ae0faf46b",
@@ -517,19 +517,80 @@ func TestWaitForKubernetesClusterState(t *testing.T) {
517517 assert .Equal (t , 3 , requestsMade )
518518}
519519
520+ func TestWaitForKubernetesNodeGroupState (t * testing.T ) {
521+ t .Parallel ()
522+
523+ requestsCounter := 0
524+ requestsMade := 0
525+
526+ srv , svc := setupTestServerAndService (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
527+ assert .Equal (t , http .MethodGet , r .Method )
528+ assert .Equal (t , fmt .Sprintf ("/%s/kubernetes/_UUID_/node-groups/_NAME_" , client .APIVersion ), r .URL .Path )
529+
530+ requestsMade ++
531+
532+ if requestsCounter >= 2 {
533+ _ , _ = fmt .Fprint (w , `
534+ {
535+ "anti_affinity": false,
536+ "count": 1,
537+ "kubelet_args": [],
538+ "labels": [],
539+ "name": "test-name",
540+ "plan": "1xCPU-1GB",
541+ "ssh_keys": [
542+ "test-key"
543+ ],
544+ "state": "running",
545+ "storage": "01000000-0000-4000-8000-000160020100",
546+ "utility_network_access": false
547+ }
548+ ` )
549+ } else {
550+ requestsCounter ++
551+ _ , _ = fmt .Fprint (w , `
552+ {
553+ "anti_affinity": false,
554+ "count": 1,
555+ "kubelet_args": [],
556+ "labels": [],
557+ "name": "test-name",
558+ "plan": "1xCPU-1GB",
559+ "ssh_keys": [
560+ "test-key"
561+ ],
562+ "state": "scaling-up",
563+ "storage": "01000000-0000-4000-8000-000160020100",
564+ "utility_network_access": false
565+ }
566+ ` )
567+ }
568+ }))
569+ defer srv .Close ()
570+
571+ _ , err := svc .WaitForKubernetesNodeGroupState (context .Background (), & request.WaitForKubernetesNodeGroupStateRequest {
572+ ClusterUUID : "_UUID_" ,
573+ DesiredState : upcloud .KubernetesNodeGroupStateRunning ,
574+ Timeout : time .Second * 20 ,
575+ Name : "_NAME_" ,
576+ })
577+ assert .NoError (t , err )
578+ assert .Equal (t , 3 , requestsMade )
579+ }
580+
520581func TestGetKubernetesKubeconfig (t * testing.T ) {
521582 t .Parallel ()
522583
523584 srv , svc := setupTestServerAndService (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
524585 // GetKubernetesKubeconfig first fetches cluster details to check for running state, so we must
525586 // take care of both requests
526587 if r .Method == http .MethodGet && r .URL .Path == fmt .Sprintf ("/%s/kubernetes/_UUID_" , client .APIVersion ) {
527- fmt .Fprint (w , exampleClusterResponse )
588+ _ , _ = fmt .Fprint (w , exampleClusterResponse )
528589 return
529590 }
530591
531592 if r .Method == http .MethodGet && r .URL .Path == fmt .Sprintf ("/%s/kubernetes/_UUID_/kubeconfig" , client .APIVersion ) {
532- fmt .Fprint (w , exampleKubeconfigResponse )
593+ _ , _ = fmt .Fprint (w , exampleKubeconfigResponse )
533594 return
534595 }
535596
0 commit comments