X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fnbi%2Fhttprestful_test.go;h=f42a835e11eb6c2a63d93cbd2fdd101c39497679;hb=bf0ea182799efa98c5e1b9c894891752848a86ce;hp=3419dcd3253d72a502595af5a27632ac2ee5ecab;hpb=0e38e1ba0b4df4e65b60ed45ed9a6638bcda44c1;p=ric-plt%2Frtmgr.git diff --git a/pkg/nbi/httprestful_test.go b/pkg/nbi/httprestful_test.go index 3419dcd..f42a835 100644 --- a/pkg/nbi/httprestful_test.go +++ b/pkg/nbi/httprestful_test.go @@ -68,6 +68,8 @@ var SubscriptionResp = []byte(`{"ID":"deadbeef1234567890", "Version":0, "EventTy var E2TListResp = []byte(`[{"e2tAddress":"127.0.0.1:0","ranNames":["RanM0","RanN0"]},{"e2tAddress":"127.0.0.1:1","ranNames":["RanM1","RanN1"]},{"e2tAddress":"127.0.0.1:2","ranNames":["RanM2","RanN2"]},{"e2tAddress":"127.0.0.1:3","ranNames":["RanM3","RanN3"]}]`) +var SubscriptionList = []byte(`[{"SubscriptionId":11,"Meid":"Test-Gnb","Endpoint":["127.0.0.1:4056"]}]`) + var InvalidSubResp = []byte(`{"Version":0, "EventType":all}`) func TestValidateXappCallbackData_1(t *testing.T) { @@ -549,6 +551,25 @@ func createMockAppmgrWithData(url string, g []byte, p []byte, t []byte) *httptes return ts } +func createMockSubmgrWithData(url string, t []byte) *httptest.Server { + l, err := net.Listen("tcp", url) + if err != nil { + fmt.Println("Failed to create listener: " + err.Error()) + } + ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + + if r.Method == "GET" && r.URL.String() == "//ric/v1/subscriptions" { + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + w.Write(t) + } + + })) + ts.Listener.Close() + ts.Listener = l + return ts +} + func createMockPlatformComponents() { var filename = "config.json" file, _ := json.MarshalIndent(stub.ValidPlatformComponents, "", "") @@ -682,6 +703,10 @@ func TestRetrieveStartupData(t *testing.T) { ts1.Start() defer ts1.Close() + ts2 := createMockSubmgrWithData("127.0.0.1:8089", SubscriptionList) + ts2.Start() + defer ts2.Close() + sdlEngine, _ := sdl.GetSdl("file") var httpRestful, _ = GetNbi("httpRESTful") createMockPlatformComponents()