associate_mc_test.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "go-common/app/service/main/vip/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaokeyBindByMid(t *testing.T) {
  10. convey.Convey("keyBindByMid", t, func(convCtx convey.C) {
  11. var (
  12. mid = int64(0)
  13. appID = int64(0)
  14. )
  15. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  16. p1 := keyBindByMid(mid, appID)
  17. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  18. convCtx.So(p1, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. // func TestDaoCacheBindInfoByMid(t *testing.T) {
  24. // convey.Convey("CacheBindInfoByMid", t, func(convCtx convey.C) {
  25. // var (
  26. // c = context.Background()
  27. // mid = int64(0)
  28. // appID = int64(0)
  29. // )
  30. // convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  31. // v, err := d.CacheBindInfoByMid(c, mid, appID)
  32. // convCtx.Convey("Then err should be nil.v should not be nil.", func(convCtx convey.C) {
  33. // convCtx.So(err, convey.ShouldBeNil)
  34. // convCtx.So(v, convey.ShouldNotBeNil)
  35. // })
  36. // })
  37. // })
  38. // }
  39. func TestDaoAddCacheBindInfoByMid(t *testing.T) {
  40. convey.Convey("AddCacheBindInfoByMid", t, func(convCtx convey.C) {
  41. var (
  42. c = context.Background()
  43. mid = int64(0)
  44. v = &model.OpenBindInfo{}
  45. appID = int64(0)
  46. )
  47. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  48. err := d.AddCacheBindInfoByMid(c, mid, v, appID)
  49. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  50. convCtx.So(err, convey.ShouldBeNil)
  51. })
  52. })
  53. })
  54. }
  55. func TestDaoDelBindInfoCache(t *testing.T) {
  56. convey.Convey("DelBindInfoCache", t, func(convCtx convey.C) {
  57. var (
  58. c = context.Background()
  59. mid = int64(0)
  60. appID = int64(0)
  61. )
  62. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  63. err := d.DelBindInfoCache(c, mid, appID)
  64. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  65. convCtx.So(err, convey.ShouldBeNil)
  66. })
  67. })
  68. })
  69. }
  70. func TestDaodelCacheUnion(t *testing.T) {
  71. convey.Convey("delCacheUnion", t, func(convCtx convey.C) {
  72. var (
  73. c = context.Background()
  74. key = "t_key"
  75. )
  76. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  77. err := d.delCache(c, key)
  78. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  79. convCtx.So(err, convey.ShouldBeNil)
  80. })
  81. })
  82. })
  83. }
  84. func TestDaoAddCacheOpenInfoByOpenID(t *testing.T) {
  85. convey.Convey("AddCacheOpenInfoByOpenID", t, func(convCtx convey.C) {
  86. var (
  87. c = context.Background()
  88. openID = "xx101"
  89. appID = int64(32)
  90. )
  91. v := &model.OpenInfo{OpenID: openID, Mid: 101, AppID: appID}
  92. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  93. err := d.AddCacheOpenInfoByOpenID(c, openID, v, appID)
  94. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  95. convCtx.So(err, convey.ShouldBeNil)
  96. })
  97. })
  98. })
  99. }
  100. func TestDaoCacheOpenInfoByOpenID(t *testing.T) {
  101. convey.Convey("CacheOpenInfoByOpenID", t, func(convCtx convey.C) {
  102. var (
  103. c = context.Background()
  104. openID = "xx101"
  105. appID = int64(32)
  106. )
  107. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  108. v, err := d.CacheOpenInfoByOpenID(c, openID, appID)
  109. fmt.Println("v--", v)
  110. convCtx.Convey("Then err should be nil.v should not be nil.", func(convCtx convey.C) {
  111. convCtx.So(err, convey.ShouldBeNil)
  112. convCtx.So(v, convey.ShouldNotBeNil)
  113. })
  114. })
  115. })
  116. }
  117. func TestDaoDelOpenInfoCache(t *testing.T) {
  118. convey.Convey("DelOpenInfoCache", t, func(convCtx convey.C) {
  119. var (
  120. c = context.Background()
  121. openID = "xx101"
  122. appID = int64(32)
  123. )
  124. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  125. err := d.DelOpenInfoCache(c, openID, appID)
  126. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  127. convCtx.So(err, convey.ShouldBeNil)
  128. })
  129. })
  130. })
  131. }