Fix test of DMaaP Mediator Producer 28/6928/1
authorelinuxhenrik <henrik.b.andersson@est.tech>
Mon, 25 Oct 2021 06:06:25 +0000 (08:06 +0200)
committerelinuxhenrik <henrik.b.andersson@est.tech>
Mon, 25 Oct 2021 06:06:32 +0000 (08:06 +0200)
Issue-ID: NONRTRIC-612
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Change-Id: Ib94010a9be3a6b2e85f6627cb19265177725f9dc

dmaap-mediator-producer/internal/jobs/jobs_test.go

index 9fe27c3..8533719 100644 (file)
@@ -165,6 +165,7 @@ func TestDeleteJob(t *testing.T) {
 func TestPollAndDistributeMessages(t *testing.T) {
        assertions := require.New(t)
 
+       wg := sync.WaitGroup{}
        messages := `[{"message": {"data": "data"}}]`
        pollClientMock := NewTestClient(func(req *http.Request) *http.Response {
                if req.URL.String() == "http://mrAddr/topicUrl" {
@@ -196,7 +197,9 @@ func TestPollAndDistributeMessages(t *testing.T) {
                t.Fail()
                return nil
        })
+
        handlerUnderTest := NewJobHandlerImpl("", pollClientMock, distributeClientMock)
+
        jobInfo := JobInfo{
                InfoTypeIdentity: "type1",
                InfoJobIdentity:  "job1",
@@ -211,7 +214,6 @@ func TestPollAndDistributeMessages(t *testing.T) {
                handlerUnderTest.clearAll()
        })
 
-       wg := sync.WaitGroup{}
        wg.Add(2) // Two calls should be made to the server, one to poll and one to distribute
        handlerUnderTest.pollAndDistributeMessages("http://mrAddr")