diff --git a/mocks/async_producer_test.go b/mocks/async_producer_test.go index e373142e6..b5d92aad8 100644 --- a/mocks/async_producer_test.go +++ b/mocks/async_producer_test.go @@ -1,13 +1,28 @@ package mocks import ( + "errors" "fmt" + "regexp" "strings" "testing" "github.com/Shopify/sarama" ) +func generateRegexpChecker(re string) func([]byte) error { + return func(val []byte) error { + matched, err := regexp.MatchString(re, string(val)) + if err != nil { + return errors.New("Error while trying to match the input message with the expected pattern: " + err.Error()) + } + if !matched { + return fmt.Errorf("No match between input value \"%s\" and expected pattern \"%s\"", val, re) + } + return nil + } +} + type testReporterMock struct { errors []string } diff --git a/mocks/mocks.go b/mocks/mocks.go index 60955a3e0..4adb838d9 100644 --- a/mocks/mocks.go +++ b/mocks/mocks.go @@ -15,8 +15,6 @@ package mocks import ( "errors" - "fmt" - "regexp" "github.com/Shopify/sarama" ) @@ -31,20 +29,6 @@ type ErrorReporter interface { // to check the value passed. type ValueChecker func(val []byte) error -// This function is used inside the mocks unit tests to generate ValueCheckers -func generateRegexpChecker(re string) func([]byte) error { - return func(val []byte) error { - matched, err := regexp.MatchString(re, string(val)) - if err != nil { - return errors.New("Error while trying to match the input message with the expected pattern: " + err.Error()) - } - if !matched { - return fmt.Errorf("No match between input value \"%s\" and expected pattern \"%s\"", val, re) - } - return nil - } -} - var ( errProduceSuccess error = nil errOutOfExpectations = errors.New("No more expectations set on mock")