diff --git a/src/caduceus/caduceus_test.go b/src/caduceus/caduceus_test.go index 917aa663..3d7762ff 100644 --- a/src/caduceus/caduceus_test.go +++ b/src/caduceus/caduceus_test.go @@ -53,10 +53,14 @@ func TestMuxServerConfig(t *testing.T) { return errors.New("time out!") } + fakeEmptyRequests := new(mockCounter) + fakeEmptyRequests.On("Add", mock.AnythingOfType("float64")).Return().Times(0) + serverWrapper := &ServerHandler{ Logger: logger, caduceusHandler: fakeHandler, caduceusHealth: fakeHealth, + emptyRequests: fakeEmptyRequests, doJob: forceTimeOut, } diff --git a/src/caduceus/http_test.go b/src/caduceus/http_test.go index ed92dff0..3fc5b75f 100644 --- a/src/caduceus/http_test.go +++ b/src/caduceus/http_test.go @@ -45,10 +45,14 @@ func TestServerHandler(t *testing.T) { return nil } + fakeEmptyRequests := new(mockCounter) + fakeEmptyRequests.On("Add", mock.AnythingOfType("float64")).Return().Times(0) + serverWrapper := &ServerHandler{ Logger: logger, caduceusHandler: fakeHandler, caduceusHealth: fakeHealth, + emptyRequests: fakeEmptyRequests, doJob: requestSuccessful, } diff --git a/src/caduceus/mocks_test.go b/src/caduceus/mocks_test.go index 8a7e7567..e9413dd3 100644 --- a/src/caduceus/mocks_test.go +++ b/src/caduceus/mocks_test.go @@ -19,6 +19,7 @@ package main import ( "github.com/Comcast/webpa-common/health" "github.com/Comcast/webpa-common/webhook" + "github.com/go-kit/kit/metrics" "github.com/stretchr/testify/mock" "net/http" "time" @@ -116,3 +117,17 @@ func (m *mockServerProfiler) Report() (values []interface{}) { func (m *mockServerProfiler) Close() { m.Called() } + +// mockCounter provides the mock implementation of the metrics.Counter object +type mockCounter struct { + mock.Mock +} + +func (m *mockCounter) Add(delta float64) { + m.Called(delta) +} + +func (m *mockCounter) With(labelValues ...string) metrics.Counter { + m.Called(labelValues) + return nil +}