mocks.go 963 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. Package mocks provides mocks that can be used for testing applications
  3. that use Sarama. The mock types provided by this package implement the
  4. interfaces Sarama exports, so you can use them for dependency injection
  5. in your tests.
  6. All mock instances require you to set expectations on them before you
  7. can use them. It will determine how the mock will behave. If an
  8. expectation is not met, it will make your test fail.
  9. NOTE: this package currently does not fall under the API stability
  10. guarantee of Sarama as it is still considered experimental.
  11. */
  12. package mocks
  13. import (
  14. "errors"
  15. )
  16. // A simple interface that includes the testing.T methods we use to report
  17. // expectation violations when using the mock objects.
  18. type ErrorReporter interface {
  19. Errorf(string, ...interface{})
  20. }
  21. var (
  22. errProduceSuccess error = nil
  23. errOutOfExpectations = errors.New("No more expectations set on mock producer")
  24. )
  25. type producerExpectation struct {
  26. Result error
  27. }