up_test.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. package manager
  2. import (
  3. "context"
  4. "go-common/app/service/main/up/dao"
  5. "go-common/app/service/main/up/model"
  6. "testing"
  7. "time"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestManagerUpSpecials(t *testing.T) {
  11. var (
  12. c = context.TODO()
  13. )
  14. convey.Convey("UpSpecials", t, func(ctx convey.C) {
  15. ups, err := d.UpSpecials(c)
  16. ctx.Convey("Then err should be nil.ups should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(ups, convey.ShouldNotBeNil)
  19. })
  20. })
  21. }
  22. func TestManagerRefreshUpSpecialIncremental(t *testing.T) {
  23. var (
  24. c = context.TODO()
  25. lastMTime = time.Now()
  26. )
  27. convey.Convey("RefreshUpSpecialIncremental", t, func(ctx convey.C) {
  28. ups, err := d.RefreshUpSpecialIncremental(c, lastMTime)
  29. ctx.Convey("Then err should be nil.ups should not be nil.", func(ctx convey.C) {
  30. ctx.So(err, convey.ShouldBeNil)
  31. ctx.So(len(ups), convey.ShouldBeGreaterThanOrEqualTo, 0)
  32. })
  33. })
  34. }
  35. func TestManagerDelSpecialByID(t *testing.T) {
  36. var (
  37. c = context.TODO()
  38. id = int64(0)
  39. )
  40. convey.Convey("DelSpecialByID", t, func(ctx convey.C) {
  41. res, err := d.DelSpecialByID(c, id)
  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. func TestManagerInsertSpecial(t *testing.T) {
  49. var (
  50. c = context.TODO()
  51. special = &model.UpSpecial{}
  52. mids = int64(0)
  53. )
  54. convey.Convey("InsertSpecial", t, func(ctx convey.C) {
  55. res, err := d.InsertSpecial(c, special, mids)
  56. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  57. ctx.So(err, convey.ShouldBeNil)
  58. ctx.So(res, convey.ShouldNotBeNil)
  59. })
  60. })
  61. }
  62. func TestManagerUpdateSpecialByID(t *testing.T) {
  63. var (
  64. c = context.TODO()
  65. id = int64(0)
  66. special = &model.UpSpecial{}
  67. )
  68. convey.Convey("UpdateSpecialByID", t, func(ctx convey.C) {
  69. res, err := d.UpdateSpecialByID(c, id, special)
  70. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  71. ctx.So(err, convey.ShouldBeNil)
  72. ctx.So(res, convey.ShouldNotBeNil)
  73. })
  74. })
  75. }
  76. func TestManagerGetSpecialByMidGroup(t *testing.T) {
  77. var (
  78. c = context.TODO()
  79. mid = int64(0)
  80. groupID = int64(0)
  81. )
  82. convey.Convey("GetSpecialByMidGroup", t, func(ctx convey.C) {
  83. res, err := d.GetSpecialByMidGroup(c, mid, groupID)
  84. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  85. ctx.So(err, convey.ShouldBeNil)
  86. ctx.So(res, convey.ShouldBeNil)
  87. })
  88. })
  89. }
  90. func TestManagerGetSpecialByID(t *testing.T) {
  91. var (
  92. c = context.TODO()
  93. id = int64(0)
  94. )
  95. convey.Convey("GetSpecialByID", t, func(ctx convey.C) {
  96. res, err := d.GetSpecialByID(c, id)
  97. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  98. ctx.So(err, convey.ShouldBeNil)
  99. ctx.So(res, convey.ShouldBeNil)
  100. })
  101. })
  102. }
  103. func TestManagerGetSepcialCount(t *testing.T) {
  104. var (
  105. c = context.TODO()
  106. conditions dao.Condition
  107. )
  108. convey.Convey("GetSepcialCount", t, func(ctx convey.C) {
  109. count, err := d.GetSepcialCount(c, conditions)
  110. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  111. ctx.So(err, convey.ShouldBeNil)
  112. ctx.So(count, convey.ShouldNotBeNil)
  113. })
  114. })
  115. }
  116. func TestManagerGetSpecial(t *testing.T) {
  117. var (
  118. c = context.TODO()
  119. conditions dao.Condition
  120. )
  121. convey.Convey("GetSpecial", t, func(ctx convey.C) {
  122. res, err := d.GetSpecial(c, conditions)
  123. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  124. ctx.So(err, convey.ShouldBeNil)
  125. ctx.So(res, convey.ShouldNotBeNil)
  126. })
  127. })
  128. }
  129. func TestManagerGetSpecialByMid(t *testing.T) {
  130. var (
  131. c = context.TODO()
  132. mid = int64(0)
  133. )
  134. convey.Convey("GetSpecialByMid", t, func(ctx convey.C) {
  135. res, err := d.GetSpecialByMid(c, mid)
  136. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  137. ctx.So(err, convey.ShouldBeNil)
  138. ctx.So(res, convey.ShouldBeNil)
  139. })
  140. })
  141. }
  142. func TestManagerRawUpSpecial(t *testing.T) {
  143. var (
  144. c = context.TODO()
  145. mid = int64(27515314)
  146. )
  147. convey.Convey("RawUpSpecial", t, func(ctx convey.C) {
  148. res, err := d.RawUpSpecial(c, mid)
  149. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  150. ctx.So(err, convey.ShouldBeNil)
  151. ctx.So(res, convey.ShouldNotBeNil)
  152. })
  153. })
  154. }
  155. func TestManagerRawUpsSpecial(t *testing.T) {
  156. var (
  157. c = context.TODO()
  158. mids = []int64{27515314}
  159. )
  160. convey.Convey("RawUpsSpecial", t, func(ctx convey.C) {
  161. res, err := d.RawUpsSpecial(c, mids)
  162. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  163. ctx.So(err, convey.ShouldBeNil)
  164. ctx.So(res, convey.ShouldNotBeNil)
  165. })
  166. })
  167. }