[VOL-3069]Pass Context in methods which are performing logging and need the context
Change-Id: I3d9e1c3eff95d60dde46d44d16bed4805f7447f5
diff --git a/pkg/mocks/kafka/kafka_client_test.go b/pkg/mocks/kafka/kafka_client_test.go
index 0e35ec1..7753d66 100644
--- a/pkg/mocks/kafka/kafka_client_test.go
+++ b/pkg/mocks/kafka/kafka_client_test.go
@@ -17,34 +17,35 @@
package kafka
import (
- "testing"
- "time"
-
+ "context"
"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
ic "github.com/opencord/voltha-protos/v3/go/inter_container"
"github.com/stretchr/testify/assert"
+ "testing"
+ "time"
)
func TestKafkaClientCreateTopic(t *testing.T) {
+ ctx := context.Background()
cTkc := NewKafkaClient()
topic := kafka.Topic{Name: "myTopic"}
- err := cTkc.CreateTopic(&topic, 1, 1)
+ err := cTkc.CreateTopic(ctx, &topic, 1, 1)
assert.Nil(t, err)
- err = cTkc.CreateTopic(&topic, 1, 1)
+ err = cTkc.CreateTopic(ctx, &topic, 1, 1)
assert.NotNil(t, err)
}
func TestKafkaClientDeleteTopic(t *testing.T) {
cTkc := NewKafkaClient()
topic := kafka.Topic{Name: "myTopic"}
- err := cTkc.DeleteTopic(&topic)
+ err := cTkc.DeleteTopic(context.Background(), &topic)
assert.Nil(t, err)
}
func TestKafkaClientSubscribeSend(t *testing.T) {
cTkc := NewKafkaClient()
topic := kafka.Topic{Name: "myTopic"}
- ch, err := cTkc.Subscribe(&topic)
+ ch, err := cTkc.Subscribe(context.Background(), &topic)
assert.Nil(t, err)
assert.NotNil(t, ch)
testCh := make(chan bool)
@@ -65,7 +66,7 @@
testCh <- false
}
}()
- err = cTkc.Send(msg, &topic)
+ err = cTkc.Send(context.Background(), msg, &topic)
assert.Nil(t, err)
res := <-testCh
assert.True(t, res)
@@ -74,20 +75,20 @@
func TestKafkaClientUnSubscribe(t *testing.T) {
cTkc := NewKafkaClient()
topic := kafka.Topic{Name: "myTopic"}
- ch, err := cTkc.Subscribe(&topic)
+ ch, err := cTkc.Subscribe(context.Background(), &topic)
assert.Nil(t, err)
assert.NotNil(t, ch)
- err = cTkc.UnSubscribe(&topic, ch)
+ err = cTkc.UnSubscribe(context.Background(), &topic, ch)
assert.Nil(t, err)
}
func TestKafkaClientStop(t *testing.T) {
cTkc := NewKafkaClient()
topic := kafka.Topic{Name: "myTopic"}
- ch, err := cTkc.Subscribe(&topic)
+ ch, err := cTkc.Subscribe(context.Background(), &topic)
assert.Nil(t, err)
assert.NotNil(t, ch)
- err = cTkc.UnSubscribe(&topic, ch)
+ err = cTkc.UnSubscribe(context.Background(), &topic, ch)
assert.Nil(t, err)
- cTkc.Stop()
+ cTkc.Stop(context.Background())
}