diff --git a/collect/collect_test.go b/collect/collect_test.go index 80a39dde20..f19df065d6 100644 --- a/collect/collect_test.go +++ b/collect/collect_test.go @@ -18,6 +18,7 @@ import ( "github.com/honeycombio/refinery/logger" "github.com/honeycombio/refinery/metrics" "github.com/honeycombio/refinery/sample" + "github.com/honeycombio/refinery/sharder" "github.com/honeycombio/refinery/transmit" "github.com/honeycombio/refinery/types" ) @@ -792,6 +793,7 @@ func TestDependencyInjection(t *testing.T) { &inject.Object{Value: &sample.SamplerFactory{}}, &inject.Object{Value: &MockStressReliever{}, Name: "stressRelief"}, &inject.Object{Value: &peer.MockPeers{}}, + &inject.Object{Value: &sharder.TestSharder{}}, ) if err != nil { t.Error(err) diff --git a/route/route_test.go b/route/route_test.go index bed5149da7..02d3c2612b 100644 --- a/route/route_test.go +++ b/route/route_test.go @@ -313,7 +313,7 @@ func TestDebugTrace(t *testing.T) { rr := httptest.NewRecorder() router := &Router{ - Sharder: &TestSharder{}, + Sharder: &sharder.TestSharder{}, } router.debugTrace(rr, req) @@ -425,7 +425,7 @@ func TestDependencyInjection(t *testing.T) { &inject.Object{Value: http.DefaultTransport, Name: "upstreamTransport"}, &inject.Object{Value: &transmit.MockTransmission{}, Name: "upstreamTransmission"}, &inject.Object{Value: &transmit.MockTransmission{}, Name: "peerTransmission"}, - &inject.Object{Value: &TestSharder{}}, + &inject.Object{Value: &sharder.TestSharder{}}, &inject.Object{Value: &collect.InMemCollector{}}, &inject.Object{Value: &metrics.NullMetrics{}, Name: "metrics"}, &inject.Object{Value: &metrics.NullMetrics{}, Name: "genericMetrics"}, @@ -440,23 +440,6 @@ func TestDependencyInjection(t *testing.T) { } } -type TestSharder struct{} - -func (s *TestSharder) MyShard() sharder.Shard { return nil } - -func (s *TestSharder) WhichShard(string) sharder.Shard { - return &TestShard{ - addr: "http://localhost:12345", - } -} - -type TestShard struct { - addr string -} - -func (s *TestShard) Equals(other sharder.Shard) bool { return true } -func (s *TestShard) GetAddress() string { return s.addr } - func TestEnvironmentCache(t *testing.T) { t.Run("calls getFn on cache miss", func(t *testing.T) { cache := newEnvironmentCache(time.Second, func(key string) (string, error) { diff --git a/sharder/mock.go b/sharder/mock.go new file mode 100644 index 0000000000..81963cc5a0 --- /dev/null +++ b/sharder/mock.go @@ -0,0 +1,18 @@ +package sharder + +type TestSharder struct{} + +func (s *TestSharder) MyShard() Shard { return nil } + +func (s *TestSharder) WhichShard(string) Shard { + return &TestShard{ + addr: "http://localhost:12345", + } +} + +type TestShard struct { + addr string +} + +func (s *TestShard) Equals(other Shard) bool { return true } +func (s *TestShard) GetAddress() string { return s.addr }