medal_test.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/usersuit/model"
  5. "math/rand"
  6. "testing"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDao_hit(t *testing.T) {
  10. Convey("return someting", t, func() {
  11. re := d.hit(1)
  12. So(re, ShouldEqual, "1")
  13. })
  14. }
  15. func TestDao_Medal(t *testing.T) {
  16. Convey("return someting", t, func() {
  17. res, err := d.Medal(context.Background())
  18. So(err, ShouldBeNil)
  19. So(res, ShouldNotBeNil)
  20. })
  21. }
  22. func TestDao_MedalByID(t *testing.T) {
  23. Convey("return someting", t, func() {
  24. re, err := d.MedalByID(context.Background(), 1)
  25. So(err, ShouldBeNil)
  26. So(re, ShouldNotBeNil)
  27. })
  28. }
  29. func TestDao_AddMedal(t *testing.T) {
  30. Convey("return someting", t, func() {
  31. pg := &model.Medal{
  32. Name: "知名偶像",
  33. Description: "红白出道,拯救高校",
  34. Condition: "所有自制视频总播放数>=100万 ",
  35. GID: 4,
  36. Level: int8(3),
  37. Sort: 3,
  38. LevelRank: "100万",
  39. IsOnline: 1,
  40. Image: "/bfs/face/27a952195555e64508310e366b3e38bd4cd143fc.png",
  41. ImageSmall: "/bfs/face/0497be49e08357bf05bca56e33a0637a273a7610.png",
  42. }
  43. id, err := d.AddMedal(context.Background(), pg)
  44. So(err, ShouldBeNil)
  45. So(id, ShouldNotBeNil)
  46. })
  47. }
  48. func TestDao_UpMedal(t *testing.T) {
  49. Convey("return someting", t, func() {
  50. pg := &model.Medal{
  51. Name: "test",
  52. Description: "Description",
  53. Condition: "Condition",
  54. GID: 1,
  55. Level: int8(3),
  56. Sort: 1,
  57. LevelRank: "LevelRank",
  58. IsOnline: 1,
  59. Image: "Image",
  60. ImageSmall: "ImageSmall",
  61. }
  62. id, err := d.UpMedal(context.Background(), 1, pg)
  63. So(err, ShouldBeNil)
  64. So(id, ShouldNotBeNil)
  65. })
  66. }
  67. func TestDao_MedalGroup(t *testing.T) {
  68. Convey("return someting", t, func() {
  69. res, err := d.MedalGroup(context.Background())
  70. So(err, ShouldBeNil)
  71. So(res, ShouldNotBeNil)
  72. })
  73. }
  74. func TestDao_MedalGroupInfo(t *testing.T) {
  75. Convey("return someting", t, func() {
  76. res, err := d.MedalGroupInfo(context.Background())
  77. So(err, ShouldBeNil)
  78. So(res, ShouldNotBeNil)
  79. })
  80. }
  81. func TestDao_MedalGroupParent(t *testing.T) {
  82. Convey("return someting", t, func() {
  83. res, err := d.MedalGroupParent(context.Background())
  84. So(err, ShouldBeNil)
  85. So(res, ShouldNotBeNil)
  86. })
  87. }
  88. func TestDao_MedalGroupByID(t *testing.T) {
  89. Convey("return someting", t, func() {
  90. re, err := d.MedalGroupByID(context.Background(), 2)
  91. So(err, ShouldBeNil)
  92. So(re, ShouldNotBeNil)
  93. })
  94. }
  95. func TestDao_MedalGroupAdd(t *testing.T) {
  96. Convey("return someting", t, func() {
  97. pg := &model.MedalGroup{
  98. Name: "test",
  99. PID: 1,
  100. Rank: int8(1),
  101. IsOnline: int8(1),
  102. }
  103. id, err := d.MedalGroupAdd(context.Background(), pg)
  104. So(err, ShouldBeNil)
  105. So(id, ShouldNotBeNil)
  106. })
  107. }
  108. func TestDao_MedalGroupUp(t *testing.T) {
  109. Convey("return someting", t, func() {
  110. pg := &model.MedalGroup{
  111. Name: "test111",
  112. PID: 2,
  113. Rank: 2,
  114. IsOnline: 0,
  115. }
  116. id, err := d.MedalGroupUp(context.Background(), 37, pg)
  117. So(err, ShouldBeNil)
  118. So(id, ShouldNotBeNil)
  119. })
  120. }
  121. func Test_MedalOwnerAdd(t *testing.T) {
  122. mid := int64(rand.Int31())
  123. Convey("return someting", t, func() {
  124. id, err := d.MedalOwnerAdd(context.Background(), mid, 1)
  125. So(err, ShouldBeNil)
  126. So(id, ShouldNotBeNil)
  127. })
  128. Convey("return someting", t, func() {
  129. _, err := d.MedalOwner(context.Background(), mid)
  130. So(err, ShouldBeNil)
  131. })
  132. }
  133. func TestDao_MedalAddList(t *testing.T) {
  134. Convey("return someting", t, func() {
  135. res, err := d.MedalAddList(context.Background(), 111)
  136. So(err, ShouldBeNil)
  137. So(res, ShouldNotBeNil)
  138. })
  139. }
  140. func TestDao_MedalOwnerUpActivated(t *testing.T) {
  141. Convey("return someting", t, func() {
  142. id, err := d.MedalOwnerUpActivated(context.Background(), 1, 1)
  143. So(err, ShouldBeNil)
  144. So(id, ShouldNotBeNil)
  145. })
  146. }
  147. func TestDao_MedalOwnerUpNotActivated(t *testing.T) {
  148. Convey("return someting", t, func() {
  149. id, err := d.MedalOwnerUpNotActivated(context.Background(), 1, 1)
  150. So(err, ShouldBeNil)
  151. So(id, ShouldNotBeNil)
  152. })
  153. }
  154. func TestDao_MedalOwnerDel(t *testing.T) {
  155. Convey("return someting", t, func() {
  156. id, err := d.MedalOwnerDel(context.Background(), 1, 1, 1)
  157. So(err, ShouldBeNil)
  158. So(id, ShouldNotBeNil)
  159. })
  160. }