NewConsumer returns a new mock Consumer instance. The t argument should be the *testing.T instance of your test method. An error will be written to it if an expectation is violated. The config argument can be set to nil; if it is non-nil it is validated.
(t ErrorReporter, config *sarama.Config)
| 23 | // an expectation is violated. The config argument can be set to nil; if it is |
| 24 | // non-nil it is validated. |
| 25 | func NewConsumer(t ErrorReporter, config *sarama.Config) *Consumer { |
| 26 | if config == nil { |
| 27 | config = sarama.NewConfig() |
| 28 | } |
| 29 | if err := config.Validate(); err != nil { |
| 30 | t.Errorf("Invalid mock configuration provided: %s", err.Error()) |
| 31 | } |
| 32 | |
| 33 | c := &Consumer{ |
| 34 | t: t, |
| 35 | config: config, |
| 36 | partitionConsumers: make(map[string]map[int32]*PartitionConsumer), |
| 37 | } |
| 38 | return c |
| 39 | } |
| 40 | |
| 41 | /////////////////////////////////////////////////// |
| 42 | // Consumer interface implementation |