cache_update_test.go 3.5 KB

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