reason_test.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/manager/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoAddCateSecExt(t *testing.T) {
  9. var (
  10. c = context.TODO()
  11. e = &model.CateSecExt{
  12. BusinessID: 1,
  13. Type: 1,
  14. Name: "测试type1",
  15. }
  16. )
  17. convey.Convey("AddCateSecExt", t, func(ctx convey.C) {
  18. err := d.AddCateSecExt(c, e)
  19. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  20. ctx.So(err, convey.ShouldBeNil)
  21. })
  22. })
  23. }
  24. func TestDaoUpdateCateSecExt(t *testing.T) {
  25. var (
  26. c = context.TODO()
  27. e = &model.CateSecExt{
  28. ID: 75,
  29. Name: "测试更新下",
  30. }
  31. )
  32. convey.Convey("UpdateCateSecExt", t, func(ctx convey.C) {
  33. err := d.UpdateCateSecExt(c, e)
  34. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. })
  37. })
  38. }
  39. func TestDaoBanCateSecExt(t *testing.T) {
  40. var (
  41. c = context.TODO()
  42. e = &model.CateSecExt{
  43. ID: 75,
  44. State: 0,
  45. }
  46. )
  47. convey.Convey("BanCateSecExt", t, func(ctx convey.C) {
  48. err := d.BanCateSecExt(c, e)
  49. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. })
  52. })
  53. }
  54. func TestDaoAddAssociation(t *testing.T) {
  55. var (
  56. c = context.TODO()
  57. e = &model.Association{
  58. BusinessID: 1,
  59. RoleID: 121,
  60. CategoryID: 212,
  61. SecondIDs: "3,7",
  62. }
  63. )
  64. convey.Convey("AddAssociation", t, func(ctx convey.C) {
  65. err := d.AddAssociation(c, e)
  66. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  67. ctx.So(err, convey.ShouldBeNil)
  68. })
  69. })
  70. }
  71. func TestDaoUpdateAssociation(t *testing.T) {
  72. var (
  73. c = context.TODO()
  74. e = &model.Association{
  75. ID: 41,
  76. RoleID: 1111,
  77. CategoryID: 2222,
  78. SecondIDs: "6,5,4,3",
  79. }
  80. )
  81. convey.Convey("UpdateAssociation", t, func(ctx convey.C) {
  82. err := d.UpdateAssociation(c, e)
  83. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  84. ctx.So(err, convey.ShouldBeNil)
  85. })
  86. })
  87. }
  88. func TestDaoBanAssociation(t *testing.T) {
  89. var (
  90. c = context.TODO()
  91. e = &model.Association{
  92. ID: 41,
  93. State: 1,
  94. }
  95. )
  96. convey.Convey("BanAssociation", t, func(ctx convey.C) {
  97. err := d.BanAssociation(c, e)
  98. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  99. ctx.So(err, convey.ShouldBeNil)
  100. })
  101. })
  102. }
  103. func TestDaoAddReason(t *testing.T) {
  104. var (
  105. c = context.TODO()
  106. e = &model.Reason{
  107. BusinessID: 1,
  108. RoleID: 99,
  109. CategoryID: 98,
  110. SecondID: 97,
  111. Common: 0,
  112. UID: 1,
  113. Description: "随便测试",
  114. Weight: 96,
  115. Flag: 0,
  116. }
  117. )
  118. convey.Convey("AddReason", t, func(ctx convey.C) {
  119. err := d.AddReason(c, e)
  120. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  121. ctx.So(err, convey.ShouldBeNil)
  122. })
  123. })
  124. }
  125. func TestDaoUpdateReason(t *testing.T) {
  126. var (
  127. c = context.TODO()
  128. e = &model.Reason{
  129. ID: 18,
  130. RoleID: 100,
  131. CategoryID: 99,
  132. SecondID: 98,
  133. Common: 1,
  134. Description: "随便测试试试",
  135. Weight: 97,
  136. Flag: 1,
  137. BusinessID: 2,
  138. TypeID: 3,
  139. TagID: 4,
  140. }
  141. )
  142. convey.Convey("UpdateReason", t, func(ctx convey.C) {
  143. err := d.UpdateReason(c, e)
  144. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  145. ctx.So(err, convey.ShouldBeNil)
  146. })
  147. })
  148. }
  149. func TestDaoReasonList(t *testing.T) {
  150. var (
  151. c = context.TODO()
  152. e = &model.SearchReasonParams{
  153. BusinessID: 1,
  154. }
  155. )
  156. convey.Convey("ReasonList", t, func(ctx convey.C) {
  157. res, err := d.ReasonList(c, e)
  158. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  159. ctx.So(err, convey.ShouldBeNil)
  160. ctx.So(res, convey.ShouldNotBeNil)
  161. })
  162. })
  163. }
  164. func TestDaoCateSecByIDs(t *testing.T) {
  165. var (
  166. c = context.TODO()
  167. ids = []int64{1, 2, 3}
  168. )
  169. convey.Convey("CateSecByIDs", t, func(ctx convey.C) {
  170. res, err := d.CateSecByIDs(c, ids)
  171. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  172. ctx.So(err, convey.ShouldBeNil)
  173. ctx.So(res, convey.ShouldNotBeNil)
  174. })
  175. })
  176. }
  177. func TestDaoBatchUpdateReasonState(t *testing.T) {
  178. var (
  179. c = context.TODO()
  180. b = &model.BatchUpdateReasonState{
  181. IDs: []int64{1, 2, 3},
  182. }
  183. )
  184. convey.Convey("BatchUpdateReasonState", t, func(ctx convey.C) {
  185. err := d.BatchUpdateReasonState(c, b)
  186. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  187. ctx.So(err, convey.ShouldBeNil)
  188. })
  189. })
  190. }
  191. func TestDaoCateSecExtList(t *testing.T) {
  192. var (
  193. c = context.TODO()
  194. e = &model.CateSecExt{
  195. BusinessID: 1,
  196. Type: 1,
  197. }
  198. )
  199. convey.Convey("CateSecExtList", t, func(ctx convey.C) {
  200. res, err := d.CateSecExtList(c, e)
  201. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  202. ctx.So(err, convey.ShouldBeNil)
  203. ctx.So(res, convey.ShouldNotBeNil)
  204. })
  205. })
  206. }
  207. func TestDaoCateSecList(t *testing.T) {
  208. var (
  209. c = context.TODO()
  210. lid = int64(0)
  211. )
  212. convey.Convey("CateSecList", t, func(ctx convey.C) {
  213. res, err := d.CateSecList(c, lid)
  214. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  215. ctx.So(err, convey.ShouldBeNil)
  216. ctx.So(res, convey.ShouldNotBeNil)
  217. })
  218. })
  219. }
  220. func TestDaoAssociationList(t *testing.T) {
  221. var (
  222. c = context.TODO()
  223. state = int64(0)
  224. lid = int64(0)
  225. )
  226. convey.Convey("AssociationList", t, func(ctx convey.C) {
  227. res, err := d.AssociationList(c, state, lid)
  228. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  229. ctx.So(err, convey.ShouldBeNil)
  230. ctx.So(res, convey.ShouldNotBeNil)
  231. })
  232. })
  233. }