memcache_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package pendant
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestPendantredPointFlagKey(t *testing.T) {
  8. convey.Convey("redPointFlagKey", t, func(ctx convey.C) {
  9. var (
  10. mid = int64(123)
  11. )
  12. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  13. p1 := redPointFlagKey(mid)
  14. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  15. ctx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. })
  19. }
  20. func TestPendantRedPointCache(t *testing.T) {
  21. convey.Convey("RedPointCache", t, func(ctx convey.C) {
  22. var (
  23. c = context.Background()
  24. mid = int64(123)
  25. )
  26. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  27. pid, err := d.RedPointCache(c, mid)
  28. ctx.Convey("Then err should be nil.pid should not be nil.", func(ctx convey.C) {
  29. ctx.So(err, convey.ShouldBeNil)
  30. ctx.So(pid, convey.ShouldNotBeNil)
  31. })
  32. })
  33. })
  34. }
  35. func TestPendantSetRedPointCache(t *testing.T) {
  36. convey.Convey("SetRedPointCache", t, func(ctx convey.C) {
  37. var (
  38. c = context.Background()
  39. mid = int64(123)
  40. pid = int64(10)
  41. )
  42. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  43. err := d.SetRedPointCache(c, mid, pid)
  44. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  45. ctx.So(err, convey.ShouldBeNil)
  46. })
  47. })
  48. })
  49. }
  50. func TestPendantDelRedPointCache(t *testing.T) {
  51. convey.Convey("DelRedPointCache", t, func(ctx convey.C) {
  52. var (
  53. c = context.Background()
  54. mid = int64(123)
  55. )
  56. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  57. err := d.DelRedPointCache(c, mid)
  58. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  59. ctx.So(err, convey.ShouldBeNil)
  60. })
  61. })
  62. })
  63. }