X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=cmd%2Fvesmgr%2Fvesmgr_queryxappconfig_test.go;h=053adcc91e3dd9fbbe17d0956c653ef3c6132ef4;hb=355364a9e9c9872a7f9a678c97a93edaff42872c;hp=11e7531b7bfa76ec3485d11971da8b7b2e2f869b;hpb=67a790ae605dff2be3ff9218df9cc359e6bd0af4;p=ric-plt%2Fvespamgr.git diff --git a/cmd/vesmgr/vesmgr_queryxappconfig_test.go b/cmd/vesmgr/vesmgr_queryxappconfig_test.go index 11e7531..053adcc 100755 --- a/cmd/vesmgr/vesmgr_queryxappconfig_test.go +++ b/cmd/vesmgr/vesmgr_queryxappconfig_test.go @@ -59,10 +59,11 @@ func runXAppMgr(listener net.Listener, url string, suite *QueryXAppsConfigTestSu switch r.Method { case "GET": suite.mu.Lock() + defer suite.mu.Unlock() suite.xAppMgrFunc(w) - suite.mu.Unlock() } }) + http.Serve(listener, nil) } @@ -70,7 +71,10 @@ func (suite *QueryXAppsConfigTestSuite) TestQueryXAppsConfigFailsWithTimeout() { doSleep := func(w http.ResponseWriter) { time.Sleep(time.Second * 2) } + + suite.mu.Lock() suite.xAppMgrFunc = doSleep + suite.mu.Unlock() data, err := queryXAppsConfig("http://"+suite.listener.Addr().String()+"/test_url/", 1) suite.Equal([]byte("{}"), data) @@ -84,7 +88,10 @@ func (suite *QueryXAppsConfigTestSuite) TestQueryXAppsConfigFailsWithAnErrorRepl doReplyWithErr := func(w http.ResponseWriter) { http.Error(w, "405 method not allowed", http.StatusMethodNotAllowed) } + + suite.mu.Lock() suite.xAppMgrFunc = doReplyWithErr + suite.mu.Unlock() data, err := queryXAppsConfig("http://"+suite.listener.Addr().String()+"/test_url/", 1) suite.Equal([]byte("{}"), data) @@ -96,7 +103,10 @@ func (suite *QueryXAppsConfigTestSuite) TestQueryXAppsConfigOk() { doReply := func(w http.ResponseWriter) { fmt.Fprintf(w, "reply message") } + + suite.mu.Lock() suite.xAppMgrFunc = doReply + suite.mu.Unlock() data, err := queryXAppsConfig("http://"+suite.listener.Addr().String()+"/test_url/", 1) suite.NotNil(data)