memcache_test.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/spy/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaopingMC(t *testing.T) {
  9. convey.Convey("pingMC", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. err := d.pingMC(c)
  15. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestDaouserInfoCacheKey(t *testing.T) {
  22. convey.Convey("userInfoCacheKey", t, func(ctx convey.C) {
  23. var (
  24. mid = int64(1)
  25. )
  26. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  27. p1 := userInfoCacheKey(mid)
  28. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  29. ctx.So(p1, convey.ShouldNotBeNil)
  30. })
  31. })
  32. })
  33. }
  34. func TestDaoUserInfoCache(t *testing.T) {
  35. convey.Convey("UserInfoCache", t, func(ctx convey.C) {
  36. var (
  37. c = context.Background()
  38. mid = int64(1)
  39. )
  40. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  41. _, err := d.UserInfoCache(c, mid)
  42. ctx.Convey("Then err should be nil.ui should not be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. })
  45. })
  46. })
  47. }
  48. func TestDaoAddUserInfoCache(t *testing.T) {
  49. convey.Convey("AddUserInfoCache", t, func(ctx convey.C) {
  50. var (
  51. c = context.Background()
  52. ui = &model.UserInfo{}
  53. )
  54. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  55. err := d.AddUserInfoCache(c, ui)
  56. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  57. ctx.So(err, convey.ShouldBeNil)
  58. })
  59. })
  60. })
  61. }
  62. func TestDaoSetUserInfoCache(t *testing.T) {
  63. convey.Convey("SetUserInfoCache", t, func(ctx convey.C) {
  64. var (
  65. c = context.Background()
  66. ui = &model.UserInfo{}
  67. )
  68. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  69. err := d.SetUserInfoCache(c, ui)
  70. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  71. ctx.So(err, convey.ShouldBeNil)
  72. })
  73. })
  74. })
  75. }
  76. func TestDaoDelInfoCache(t *testing.T) {
  77. convey.Convey("DelInfoCache", t, func(ctx convey.C) {
  78. var (
  79. c = context.Background()
  80. mid = int64(1)
  81. )
  82. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  83. err := d.DelInfoCache(c, mid)
  84. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  85. ctx.So(err, convey.ShouldBeNil)
  86. })
  87. })
  88. })
  89. }