Added SubscribeForMetadata() to the sarama client, to access the header field of each received message.
Also replaced TestKafkaClientImplementsKafkaClientIf() with static checks.
For VOL-2207. Please consider these related patchsets together:
https://gerrit.opencord.org/#/q/VOL-2207
Change-Id: I77f03fbb0ebcdf60cb5f8d0c8c3276325510e874
diff --git a/pkg/mocks/kafka_client.go b/pkg/mocks/kafka_client.go
index 51bd532..62af5db 100644
--- a/pkg/mocks/kafka_client.go
+++ b/pkg/mocks/kafka_client.go
@@ -26,6 +26,9 @@
"google.golang.org/grpc/status"
)
+// static check to ensure KafkaClient implements kafka.Client
+var _ kafka.Client = &KafkaClient{}
+
type KafkaClient struct {
topicsChannelMap map[string][]chan *ic.InterContainerMessage
lock sync.RWMutex
@@ -108,6 +111,10 @@
return nil
}
+func (kc *KafkaClient) SubscribeForMetadata(_ func(fromTopic string, timestamp int64)) {
+ panic("unimplemented")
+}
+
func (kc *KafkaClient) Send(msg interface{}, topic *kafka.Topic, keys ...string) error {
req, ok := msg.(*ic.InterContainerMessage)
if !ok {
diff --git a/pkg/mocks/kafka_client_test.go b/pkg/mocks/kafka_client_test.go
index e4517cc..dcf1973 100644
--- a/pkg/mocks/kafka_client_test.go
+++ b/pkg/mocks/kafka_client_test.go
@@ -25,14 +25,6 @@
"github.com/stretchr/testify/assert"
)
-func TestKafkaClientImplementsKafkaClientIf(t *testing.T) {
- client := NewKafkaClient()
-
- if _, ok := interface{}(client).(kafka.Client); !ok {
- t.Error("mock kafka client does not implement voltha-lib-go/v3/pkg/kafka/Client interface")
- }
-}
-
func TestKafkaClientCreateTopic(t *testing.T) {
cTkc := NewKafkaClient()
topic := kafka.Topic{Name: "myTopic"}