redis_test.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. var (
  9. ctx = context.TODO()
  10. mid int64 = 7593623
  11. )
  12. func Test_FrozenQueue(t *testing.T) {
  13. Convey("Test_FrozenQueue", t, func() {
  14. var (
  15. err error
  16. score = time.Now().Add(-50 * time.Second).Unix()
  17. )
  18. err = d.Enqueue(ctx, mid, score)
  19. So(err, ShouldBeNil)
  20. res, err2 := d.Dequeue(ctx)
  21. So(err2, ShouldBeNil)
  22. So(res[0], ShouldEqual, mid)
  23. err3 := d.RemQueue(ctx, mid)
  24. So(err3, ShouldBeNil)
  25. })
  26. }
  27. func TestDao_Enqueue(t *testing.T) {
  28. Convey("test enqueue", t, func() {
  29. duration := time.Duration(d.c.Property.FrozenDate)
  30. t.Logf("duration %+v", duration)
  31. err := d.Enqueue(ctx, mid, time.Now().Add(duration).Unix())
  32. So(err, ShouldBeNil)
  33. })
  34. }
  35. func TestDao_Dequeue(t *testing.T) {
  36. Convey("dequeue", t, func() {
  37. res, err := d.Dequeue(ctx)
  38. t.Logf("%+v", res)
  39. So(err, ShouldBeNil)
  40. })
  41. }
  42. func Test_AddLogginIP(t *testing.T) {
  43. Convey("Test_FrozenQueue", t, func() {
  44. err := d.AddLogginIP(ctx, mid, 234231)
  45. So(err, ShouldBeNil)
  46. })
  47. }