mercredi 25 octobre 2017

Mocking NewConsumer in sarama-cluster

Is there a way to test/mock sarama-cluster's NewConsumer function without having actual brokers set up? What am I missing here?

Code I'm trying to test:

import cluster "http://ift.tt/1TgZOro"

func initSaramaConsumer() (*cluster.Consumer, err) {
  brokers := []string{"some_url:port"}
  groups := []string{"some_group"}
  topics := []string{"some_topic"}
  config := cluster.NewConfig()

  saramaConsumer, err := cluster.NewConsumer(
    brokers, groups, topics, config,
  )

  if err != nil {
    return nil, err
  }

  return saramaConsumer, nil
}

Aucun commentaire:

Enregistrer un commentaire