redis_test.go 578 B

12345678910111213141516171819202122232425262728
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/job/main/dm/conf"
  6. )
  7. func TestDuration(t *testing.T) {
  8. var (
  9. err error
  10. res int64
  11. cid = int64(1)
  12. duration = int64(100)
  13. c = context.TODO()
  14. )
  15. d := New(conf.Conf)
  16. if err = d.SetDurationCache(c, cid, duration); err != nil {
  17. t.Errorf("d.SetDurationCache(%d,%d) error(%v)", cid, duration, err)
  18. }
  19. if res, err = d.DurationCache(c, cid); err != nil {
  20. t.Errorf("d.DurationCache(%d) error(%v)", cid, err)
  21. }
  22. if res != duration {
  23. t.Errorf("not expect value %d,%d", duration, res)
  24. }
  25. }