X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dmaap-mediator-producer%2Finternal%2Fjobs%2Fjobs_test.go;h=552b5fa103b7096b1d639f5958ff59dc5c078c13;hb=46a0fd717e5f49ebae6cb2c4fbcf54f0e329dc86;hp=e48e68d1f9229bd7fca47b60c1328b34fdf064cd;hpb=036962c60e1cfa18a689dffa1a8b92d335e6063e;p=nonrtric.git diff --git a/dmaap-mediator-producer/internal/jobs/jobs_test.go b/dmaap-mediator-producer/internal/jobs/jobs_test.go index e48e68d1..552b5fa1 100644 --- a/dmaap-mediator-producer/internal/jobs/jobs_test.go +++ b/dmaap-mediator-producer/internal/jobs/jobs_test.go @@ -177,7 +177,7 @@ func TestAddJobToJobsManager_shouldStartPollAndDistributeMessages(t *testing.T) distributeClientMock := NewTestClient(func(req *http.Request) *http.Response { if req.URL.String() == "http://consumerHost/target" { assertions.Equal(req.Method, "POST") - assertions.Equal(messages, getBodyAsString(req)) + assertions.Equal(messages, getBodyAsString(req, t)) assertions.Equal("application/json", req.Header.Get("Content-Type")) wg.Done() return &http.Response{ @@ -208,7 +208,8 @@ func TestAddJobToJobsManager_shouldStartPollAndDistributeMessages(t *testing.T) } wg.Add(1) // Wait till the distribution has happened - jobsManager.AddJobFromRESTCall(jobInfo) + err := jobsManager.AddJobFromRESTCall(jobInfo) + assertions.Nil(err) if waitTimeout(&wg, 2*time.Second) { t.Error("Not all calls to server were made") @@ -287,8 +288,10 @@ func waitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool { } } -func getBodyAsString(req *http.Request) string { +func getBodyAsString(req *http.Request, t *testing.T) string { buf := new(bytes.Buffer) - buf.ReadFrom(req.Body) + if _, err := buf.ReadFrom(req.Body); err != nil { + t.Fail() + } return buf.String() }