add test for cache miss
This commit is contained in:
parent
36e9aa49f7
commit
2a574d6f3b
1 changed files with 15 additions and 0 deletions
15
cache/cache_test.go
vendored
15
cache/cache_test.go
vendored
|
@ -32,3 +32,18 @@ func TestCacheGet(t *testing.T) {
|
|||
t.Fatalf("cache.Get(\"1.2.3.4\") = %f, want %f", score.Score, testFloat)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCacheMiss(t *testing.T) {
|
||||
now := time.Now()
|
||||
const testFloat = 1.23456
|
||||
|
||||
expiredTime := now.Add(-(time.Minute * 10))
|
||||
|
||||
cache := NewLocalCache()
|
||||
cache.Add(testFloat, netip.MustParseAddr("1.2.3.4"), expiredTime)
|
||||
|
||||
_, err := cache.Get(netip.MustParseAddr("1.2.3.4"))
|
||||
if err == nil {
|
||||
t.Fatalf("cache.Get(\"1.2.3.4\") = got nil, want error")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue