go-common/library/cache/cache_test.go

21 lines
273 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package cache
import (
"testing"
"time"
)
func TestCache_Save(t *testing.T) {
ca := New(1, 1024)
var run bool
ca.Save(func() {
run = true
panic("error")
})
time.Sleep(time.Millisecond * 50)
t.Log("don't panic")
if !run {
t.Fatal("expect run be true")
}
}