relation_test.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. package dao
  2. import (
  3. "context"
  4. relation "go-common/app/service/main/relation/model"
  5. xtime "go-common/library/time"
  6. "testing"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaostatKey(t *testing.T) {
  10. var (
  11. mid = int64(1)
  12. )
  13. convey.Convey("statKey", t, func(ctx convey.C) {
  14. p1 := statKey(mid)
  15. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  16. ctx.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. }
  20. func TestDaotagsKey(t *testing.T) {
  21. var (
  22. mid = int64(1)
  23. )
  24. convey.Convey("tagsKey", t, func(ctx convey.C) {
  25. p1 := tagsKey(mid)
  26. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  27. ctx.So(p1, convey.ShouldNotBeNil)
  28. })
  29. })
  30. }
  31. func TestDaofollowingsKey(t *testing.T) {
  32. var (
  33. mid = int64(1)
  34. )
  35. convey.Convey("followingsKey", t, func(ctx convey.C) {
  36. p1 := followingsKey(mid)
  37. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  38. ctx.So(p1, convey.ShouldNotBeNil)
  39. })
  40. })
  41. }
  42. func TestDaofollowingKey(t *testing.T) {
  43. var (
  44. mid = int64(1)
  45. )
  46. convey.Convey("followingKey", t, func(ctx convey.C) {
  47. p1 := followingKey(mid)
  48. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  49. ctx.So(p1, convey.ShouldNotBeNil)
  50. })
  51. })
  52. }
  53. func TestDaotagCountKey(t *testing.T) {
  54. var (
  55. mid = int64(1)
  56. )
  57. convey.Convey("tagCountKey", t, func(ctx convey.C) {
  58. p1 := tagCountKey(mid)
  59. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  60. ctx.So(p1, convey.ShouldNotBeNil)
  61. })
  62. })
  63. }
  64. func TestDaoDelStatCache(t *testing.T) {
  65. var (
  66. c = context.Background()
  67. mid = int64(1)
  68. )
  69. convey.Convey("DelStatCache", t, func(ctx convey.C) {
  70. err := d.DelStatCache(c, mid)
  71. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. })
  74. })
  75. }
  76. func TestDaoDelFollowerCache(t *testing.T) {
  77. var (
  78. c = context.Background()
  79. mid = int64(1)
  80. )
  81. convey.Convey("DelFollowerCache", t, func(ctx convey.C) {
  82. err := d.DelFollowerCache(c, mid)
  83. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  84. ctx.So(err, convey.ShouldBeNil)
  85. })
  86. })
  87. }
  88. func TestDaoDelFollowing(t *testing.T) {
  89. var (
  90. c = context.Background()
  91. mid = int64(1)
  92. following = &relation.Following{}
  93. )
  94. convey.Convey("DelFollowing", t, func(ctx convey.C) {
  95. err := d.DelFollowing(c, mid, following)
  96. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  97. ctx.So(err, convey.ShouldBeNil)
  98. })
  99. })
  100. }
  101. func TestDaoDelTagsCache(t *testing.T) {
  102. var (
  103. c = context.Background()
  104. mid = int64(1)
  105. )
  106. convey.Convey("DelTagsCache", t, func(ctx convey.C) {
  107. err := d.DelTagsCache(c, mid)
  108. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  109. ctx.So(err, convey.ShouldBeNil)
  110. })
  111. })
  112. }
  113. func TestDaoAddFollowingCache(t *testing.T) {
  114. var (
  115. c = context.Background()
  116. mid = int64(1)
  117. following = &relation.Following{}
  118. )
  119. convey.Convey("AddFollowingCache", t, func(ctx convey.C) {
  120. err := d.AddFollowingCache(c, mid, following)
  121. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  122. ctx.So(err, convey.ShouldBeNil)
  123. })
  124. })
  125. }
  126. func TestDaoencode(t *testing.T) {
  127. var (
  128. attribute = uint32(1)
  129. mtime xtime.Time
  130. tagids = []int64{1}
  131. special = int32(1)
  132. )
  133. convey.Convey("encode", t, func(ctx convey.C) {
  134. res, err := d.encode(attribute, mtime, tagids, special)
  135. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  136. ctx.So(err, convey.ShouldBeNil)
  137. ctx.So(res, convey.ShouldNotBeNil)
  138. })
  139. })
  140. }
  141. func TestDaoDelFollowingCache(t *testing.T) {
  142. var (
  143. c = context.Background()
  144. mid = int64(1)
  145. )
  146. convey.Convey("DelFollowingCache", t, func(ctx convey.C) {
  147. err := d.DelFollowingCache(c, mid)
  148. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  149. ctx.So(err, convey.ShouldBeNil)
  150. })
  151. })
  152. }
  153. func TestDaodelFollowingCache(t *testing.T) {
  154. var (
  155. c = context.Background()
  156. key = ""
  157. )
  158. convey.Convey("delFollowingCache", t, func(ctx convey.C) {
  159. err := d.delFollowingCache(c, key)
  160. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  161. ctx.So(err, convey.ShouldBeNil)
  162. })
  163. })
  164. }
  165. func TestDaoDelTagCountCache(t *testing.T) {
  166. var (
  167. c = context.Background()
  168. mid = int64(0)
  169. )
  170. convey.Convey("DelTagCountCache", t, func(ctx convey.C) {
  171. err := d.DelTagCountCache(c, mid)
  172. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  173. ctx.So(err, convey.ShouldBeNil)
  174. })
  175. })
  176. }