cachestat_test.go 521 B

12345678910111213141516171819202122232425262728
  1. package cache
  2. import (
  3. "testing"
  4. "github.com/wuntsong-org/go-zero-plus/core/timex"
  5. )
  6. func TestCacheStat_statLoop(t *testing.T) {
  7. t.Run("stat loop total 0", func(t *testing.T) {
  8. var stat Stat
  9. ticker := timex.NewFakeTicker()
  10. go stat.statLoop(ticker)
  11. ticker.Tick()
  12. ticker.Tick()
  13. ticker.Stop()
  14. })
  15. t.Run("stat loop total not 0", func(t *testing.T) {
  16. var stat Stat
  17. stat.IncrementTotal()
  18. ticker := timex.NewFakeTicker()
  19. go stat.statLoop(ticker)
  20. ticker.Tick()
  21. ticker.Tick()
  22. ticker.Stop()
  23. })
  24. }