X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=pkg%2Fresthooks%2Fresthooks_test.go;fp=pkg%2Fresthooks%2Fresthooks_test.go;h=517fb1111d2729927f478c260a19c0c3a07bc6bd;hb=6e8d970e6ec582bd4473c3fbb6772906658608ca;hp=74ba05ea788a496082979acbfdd5c94feb81becd;hpb=04897e6ba579f0cfd11453f589fc1fb24be4e820;p=ric-plt%2Fricdms.git diff --git a/pkg/resthooks/resthooks_test.go b/pkg/resthooks/resthooks_test.go index 74ba05e..517fb11 100644 --- a/pkg/resthooks/resthooks_test.go +++ b/pkg/resthooks/resthooks_test.go @@ -29,9 +29,11 @@ import ( "os" "testing" + ch "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/charts" "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/health" "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/models" "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/onboard" + "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations/charts" h "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations/health" "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/ricdms" "github.com/stretchr/testify/assert" @@ -50,6 +52,7 @@ func TestMain(m *testing.M) { rh = &Resthook{ HealthChecker: HealthCheckerMock{}, Onboarder: onboard.NewOnboarder(), + ChartMgr: ch.NewChartmgr(), } code := m.Run() os.Exit(code) @@ -102,6 +105,25 @@ func TestOnboard(t *testing.T) { assert.NotEqual(t, nil, resp) } +func TestGetCharts(t *testing.T) { + + svr := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ricdms.Logger.Debug("Mock server running") + fmt.Fprintf(w, "SAMPLE_RESPONSE") + })) + svr.Listener.Close() + svr.Listener, _ = net.Listen("tcp", ricdms.Config.MockServer) + + svr.Start() + defer svr.Close() + + resp := rh.GetCharts() + assert.NotEqual(t, nil, resp) + + successResp := resp.(*charts.GetChartsListOK) + assert.Equal(t, "SAMPLE_RESPONSE", successResp.Payload) +} + type HealthCheckerMock struct { mock.Mock }