mc_limiter_test.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/interface/main/dm2/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaokeyDmDailyLimit(t *testing.T) {
  9. convey.Convey("keyDmDailyLimit", t, func(ctx convey.C) {
  10. var (
  11. mid = int64(0)
  12. )
  13. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  14. p1 := keyDmDailyLimit(mid)
  15. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  16. ctx.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestDaoSetDmDailyLimitCache(t *testing.T) {
  22. convey.Convey("SetDmDailyLimitCache", t, func(ctx convey.C) {
  23. var (
  24. c = context.Background()
  25. mid = int64(0)
  26. limiter = &model.DailyLimiter{}
  27. )
  28. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  29. err := testDao.SetDmDailyLimitCache(c, mid, limiter)
  30. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  31. ctx.So(err, convey.ShouldBeNil)
  32. })
  33. })
  34. })
  35. }
  36. func TestDaoGetDmDailyLimitCache(t *testing.T) {
  37. convey.Convey("GetDmDailyLimitCache", t, func(ctx convey.C) {
  38. var (
  39. c = context.Background()
  40. mid = int64(0)
  41. )
  42. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  43. limiter, err := testDao.GetDmDailyLimitCache(c, mid)
  44. ctx.Convey("Then err should be nil.limiter should not be nil.", func(ctx convey.C) {
  45. ctx.So(err, convey.ShouldBeNil)
  46. ctx.So(limiter, convey.ShouldNotBeNil)
  47. })
  48. })
  49. })
  50. }