memcache_test.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/point/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaopointKey(t *testing.T) {
  9. convey.Convey("pointKey", t, func(ctx convey.C) {
  10. var (
  11. mid = int64(0)
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. p1 := pointKey(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 TestDaoDelPointInfoCache(t *testing.T) {
  22. convey.Convey("DelPointInfoCache", t, func(ctx convey.C) {
  23. var (
  24. c = context.Background()
  25. mid = int64(0)
  26. )
  27. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  28. err := d.DelPointInfoCache(c, mid)
  29. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  30. ctx.So(err, convey.ShouldBeNil)
  31. })
  32. })
  33. })
  34. }
  35. func TestDaoPointInfoCache(t *testing.T) {
  36. convey.Convey("PointInfoCache", t, func(ctx convey.C) {
  37. var (
  38. c = context.Background()
  39. mid = int64(0)
  40. )
  41. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  42. _, err := d.PointInfoCache(c, mid)
  43. ctx.Convey("Then err should be nil.pi should not be nil.", func(ctx convey.C) {
  44. ctx.So(err, convey.ShouldBeNil)
  45. })
  46. })
  47. })
  48. }
  49. func TestDaoSetPointInfoCache(t *testing.T) {
  50. convey.Convey("SetPointInfoCache", t, func(ctx convey.C) {
  51. var (
  52. c = context.Background()
  53. pi = &model.PointInfo{}
  54. )
  55. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  56. err := d.SetPointInfoCache(c, pi)
  57. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  58. ctx.So(err, convey.ShouldBeNil)
  59. })
  60. })
  61. })
  62. }
  63. func TestDaodelCache(t *testing.T) {
  64. convey.Convey("delCache", t, func(ctx convey.C) {
  65. var (
  66. c = context.Background()
  67. key = "1"
  68. )
  69. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  70. err := d.delCache(c, key)
  71. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. })
  74. })
  75. })
  76. }