mc.cache_test.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/card/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoequipKey(t *testing.T) {
  9. convey.Convey("equipKey", 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 := equipKey(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 TestDaopingMC(t *testing.T) {
  22. convey.Convey("pingMC", t, func(ctx convey.C) {
  23. var (
  24. c = context.Background()
  25. )
  26. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  27. err := d.pingMC(c)
  28. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  29. ctx.So(err, convey.ShouldBeNil)
  30. })
  31. })
  32. })
  33. }
  34. func TestDaoCacheEquips(t *testing.T) {
  35. convey.Convey("CacheEquips", t, func(ctx convey.C) {
  36. var (
  37. c = context.Background()
  38. mids = []int64{1, 2, 3}
  39. )
  40. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  41. res, err := d.CacheEquips(c, mids)
  42. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. ctx.So(res, convey.ShouldNotBeNil)
  45. })
  46. })
  47. })
  48. }
  49. func TestDaoCacheEquip(t *testing.T) {
  50. convey.Convey("CacheEquip", t, func(ctx convey.C) {
  51. var (
  52. c = context.Background()
  53. mid = int64(2)
  54. )
  55. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  56. _, err := d.CacheEquip(c, mid)
  57. ctx.Convey("Then err should be nil.v should not be nil.", func(ctx convey.C) {
  58. ctx.So(err, convey.ShouldBeNil)
  59. })
  60. })
  61. })
  62. }
  63. func TestDaoAddCacheEquips(t *testing.T) {
  64. convey.Convey("AddCacheEquips", t, func(ctx convey.C) {
  65. var (
  66. c = context.Background()
  67. values map[int64]*model.UserEquip
  68. )
  69. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  70. err := d.AddCacheEquips(c, values)
  71. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. })
  74. })
  75. })
  76. }
  77. func TestDaoAddCacheEquip(t *testing.T) {
  78. convey.Convey("AddCacheEquip", t, func(ctx convey.C) {
  79. var (
  80. c = context.Background()
  81. mid = int64(0)
  82. v = &model.UserEquip{}
  83. )
  84. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  85. err := d.AddCacheEquip(c, mid, v)
  86. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  87. ctx.So(err, convey.ShouldBeNil)
  88. })
  89. })
  90. })
  91. }
  92. func TestDaoDelCacheEquips(t *testing.T) {
  93. convey.Convey("DelCacheEquips", t, func(ctx convey.C) {
  94. var (
  95. c = context.Background()
  96. ids = []int64{}
  97. )
  98. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  99. err := d.DelCacheEquips(c, ids)
  100. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  101. ctx.So(err, convey.ShouldBeNil)
  102. })
  103. })
  104. })
  105. }
  106. func TestDaoDelCacheEquip(t *testing.T) {
  107. convey.Convey("DelCacheEquip", t, func(ctx convey.C) {
  108. var (
  109. c = context.Background()
  110. id = int64(0)
  111. )
  112. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  113. err := d.DelCacheEquip(c, id)
  114. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  115. ctx.So(err, convey.ShouldBeNil)
  116. })
  117. })
  118. })
  119. }