@@ -55,6 +55,29 @@ func RestartService() (*http.Response, error) {
55
55
return response , err
56
56
}
57
57
58
+ func GetNodes () (* http.Response , error ) {
59
+ /*
60
+ Helper function to get nodes
61
+ HTTP Verb: GET
62
+ URL: /api/v1/nodes
63
+ */
64
+ request , err := http .NewRequest (
65
+ "GET" ,
66
+ "http://localhost:9090/api/v1/nodes" ,
67
+ nil ,
68
+ )
69
+ if err != nil {
70
+ log .Println (err )
71
+ }
72
+ request .Header .Add ("Cookie" , fmt .Sprintf ("token=%s" , token ))
73
+ request .Header .Add ("Content-Type" , "application/json" )
74
+ client := & http.Client {
75
+ Timeout : 2000 * time .Second , // increased timeout since restart takes time, more than other APIs.
76
+ }
77
+ response , err := client .Do (request )
78
+ return response , err
79
+ }
80
+
58
81
func NotifyPostgres () (* http.Response , error ) {
59
82
/*
60
83
Helper function to add Postgres Notification
@@ -257,3 +280,23 @@ func TestListUsersWithAccessToBucket(t *testing.T) {
257
280
}
258
281
259
282
}
283
+
284
+ func TestGetNodes (t * testing.T ) {
285
+
286
+ assert := assert .New (t )
287
+ getNodesResponse , getNodesError := GetNodes ()
288
+ assert .Nil (getNodesError )
289
+ if getNodesError != nil {
290
+ log .Println (getNodesError )
291
+ return
292
+ }
293
+ addObjRsp := inspectHTTPResponse (getNodesResponse )
294
+ if getNodesResponse != nil {
295
+ assert .Equal (
296
+ 200 ,
297
+ getNodesResponse .StatusCode ,
298
+ addObjRsp ,
299
+ )
300
+ }
301
+
302
+ }
0 commit comments