Skip to content

Commit

Permalink
Supply StatManager in memcache tests
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Radnic <[email protected]>
  • Loading branch information
pradnic committed Jun 2, 2021
1 parent d03eba2 commit a3b6752
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/stats/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ type ShouldRateLimitLegacyStats struct {
}

// Stats for an individual rate limit config entry.
// todo: Ideally the gostats package fields should be unexported
// the inner value could be interacted with via getters such as rlStats.TotalHits() uint64
// This ensures that setters such as Inc() and Add() can only be managed by RateLimitStats.
type RateLimitStats struct {
Key string
TotalHits gostats.Counter
Expand Down
4 changes: 2 additions & 2 deletions test/memcached/cache_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ func TestNewRateLimitCacheImplFromSettingsWhenSrvCannotBeResolved(t *testing.T)
s.ExpirationJitterMaxSeconds = 300
s.MemcacheSrv = "_something._tcp.example.invalid"

assert.Panics(func() { memcached.NewRateLimitCacheImplFromSettings(s, timeSource, nil, nil, statsStore) })
assert.Panics(func() { memcached.NewRateLimitCacheImplFromSettings(s, timeSource, nil, nil, statsStore, mockstats.NewMockStatManager(statsStore)) })
}

func TestNewRateLimitCacheImplFromSettingsWhenHostAndPortAndSrvAreBothSet(t *testing.T) {
Expand All @@ -623,7 +623,7 @@ func TestNewRateLimitCacheImplFromSettingsWhenHostAndPortAndSrvAreBothSet(t *tes
s.MemcacheSrv = "_something._tcp.example.invalid"
s.MemcacheHostPort = []string{"example.org:11211"}

assert.Panics(func() { memcached.NewRateLimitCacheImplFromSettings(s, timeSource, nil, nil, statsStore) })
assert.Panics(func() { memcached.NewRateLimitCacheImplFromSettings(s, timeSource, nil, nil, statsStore, mockstats.NewMockStatManager(statsStore)) })
}

func getMultiResult(vals map[string]int) map[string]*memcache.Item {
Expand Down
1 change: 0 additions & 1 deletion test/mocks/stats/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func (m *MockStatManager) NewShouldRateLimitLegacyStats() stats.ShouldRateLimitL
}
}

//todo: review mock implementation
func (m *MockStatManager) NewStats(key string) stats.RateLimitStats {
ret := stats.RateLimitStats{}
logger.Debugf("outputing test gostats %s", key)
Expand Down

0 comments on commit a3b6752

Please sign in to comment.