76d5c5f82145aa92f458220aea844b740d4dd673
[ric-plt/xapp-frame.git] / pkg / xapp / restapi_test.go
1 package xapp
2
3 import (
4         "net/http"
5         "net/http/httptest"
6         "testing"
7 )
8
9 func TestGetHealthReadyCheck(t *testing.T) {
10         req, err := http.NewRequest("GET", "/ric/v1/health/ready", nil)
11         if err != nil {
12                 t.Fatal(err)
13         }
14         rr := httptest.NewRecorder()
15         handler := http.HandlerFunc(readyHandler)
16         handler.ServeHTTP(rr, req)
17         if status := rr.Code; status != http.StatusOK {
18                 t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK)
19         }
20         //expected := `{"ready": true}`
21         //if rr.Body.String() != expected {
22         //  t.Errorf("handler returned unexpected body: got %v want %v", rr.Body.String(), expected)
23         //}
24 }
25
26 func TestGetHealthAliveCheck(t *testing.T) {
27         req, err := http.NewRequest("GET", "/ric/v1/health/alive", nil)
28         if err != nil {
29                 t.Fatal(err)
30         }
31         rr := httptest.NewRecorder()
32         handler := http.HandlerFunc(aliveHandler)
33         handler.ServeHTTP(rr, req)
34         if status := rr.Code; status != http.StatusOK {
35                 t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK)
36         }
37         //expected := `{"alive": true}`
38         //if rr.Body.String() != expected {
39         //  t.Errorf("handler returned unexpected body: got %v want %v", rr.Body.String(), expected)
40         //}
41 }