Better test
This commit is contained in:
parent
d5307b40af
commit
3665b16e83
1 changed files with 2 additions and 7 deletions
|
@ -27,16 +27,11 @@ func (_ CacheTests) FetchesExpiredItems() {
|
||||||
cache := New(Configure())
|
cache := New(Configure())
|
||||||
fn := func() (interface{}, error) { return "moo-moo", nil }
|
fn := func() (interface{}, error) { return "moo-moo", nil }
|
||||||
|
|
||||||
cache.Set("beef", "moo", time.Second)
|
cache.Set("beef", "moo", time.Second*-1)
|
||||||
Expect(cache.Get("beef").Value()).To.Equal("moo")
|
Expect(cache.Get("beef").Value()).To.Equal("moo")
|
||||||
|
|
||||||
out, _ := cache.Fetch("beef", time.Second, fn)
|
out, _ := cache.Fetch("beef", time.Second, fn)
|
||||||
Expect(out.Value()).To.Equal("moo")
|
Expect(out.Value()).To.Equal("moo-moo")
|
||||||
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
out2, _ := cache.Fetch("beef", time.Second, fn)
|
|
||||||
Expect(out2.Value()).To.Equal("moo-moo")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ CacheTests) GCsTheOldestItems() {
|
func (_ CacheTests) GCsTheOldestItems() {
|
||||||
|
|
Loading…
Reference in a new issue