cache_test.go 273 B

1234567891011121314151617181920
  1. package cache
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. func TestCache_Save(t *testing.T) {
  7. ca := New(1, 1024)
  8. var run bool
  9. ca.Save(func() {
  10. run = true
  11. panic("error")
  12. })
  13. time.Sleep(time.Millisecond * 50)
  14. t.Log("don't panic")
  15. if !run {
  16. t.Fatal("expect run be true")
  17. }
  18. }