package kafka

import (
	"errors"
	"testing"

	"github.com/fiskerinc/cloud-services/pkg/testhelper"
	"github.com/confluentinc/confluent-kafka-go/v2/kafka"
)

func TestConsumer(t *testing.T) {
	t.Skip()

	c, err := kafka.NewConsumer(&kafka.ConfigMap{
		"group.id":                 "gotest",
		"socket.timeout.ms":        1000,
		"session.timeout.ms":       1000,
		"enable.auto.offset.store": false,
	})
	if err != nil {
		t.Errorf(testhelper.TestErrorTemplate, "TestConsumer", nil, err)
	}

	consumer := &Consumer{consumer: c}
	channel := make(chan *kafka.Message)

	go consumer.ConsumeToChannel([]string{"gotest"}, channel)
	consumer.Stop()
}

func TestConsumerError(t *testing.T) {
	t.Skip()

	c, err := kafka.NewConsumer(&kafka.ConfigMap{
		"socket.timeout.ms":        1000,
		"session.timeout.ms":       1000,
		"enable.auto.offset.store": false,
	})
	if err == nil {
		t.Errorf(testhelper.TestErrorTemplate, "TestConsumerError", errors.New("Required property group.id not set"), err)
	}
	if c != nil {
		t.Errorf(testhelper.TestErrorTemplate, "TestConsumerError", nil, c)
	}
}
