mysql_test.go 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. package dao
  2. import (
  3. "context"
  4. xtime "go-common/library/time"
  5. "testing"
  6. "time"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoSubject(t *testing.T) {
  10. convey.Convey("Subject", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. tp = int32(0)
  14. oid = int64(0)
  15. )
  16. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  17. testDao.Subject(c, tp, oid)
  18. })
  19. })
  20. }
  21. func TestDaoSubjects(t *testing.T) {
  22. convey.Convey("Subjects", t, func(ctx convey.C) {
  23. var (
  24. c = context.Background()
  25. tp = int32(0)
  26. oids = []int64{}
  27. )
  28. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  29. testDao.Subjects(c, tp, oids)
  30. })
  31. })
  32. }
  33. func TestDaoUptSubAttr(t *testing.T) {
  34. convey.Convey("UptSubAttr", t, func(ctx convey.C) {
  35. var (
  36. c = context.Background()
  37. tp = int32(0)
  38. oid = int64(0)
  39. attr = int32(0)
  40. )
  41. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  42. affect, err := testDao.UptSubAttr(c, tp, oid, attr)
  43. ctx.Convey("Then err should be nil.affect should not be nil.", func(ctx convey.C) {
  44. ctx.So(err, convey.ShouldBeNil)
  45. ctx.So(affect, convey.ShouldNotBeNil)
  46. })
  47. })
  48. })
  49. }
  50. func TestDaoIncrSubMoveCount(t *testing.T) {
  51. convey.Convey("IncrSubMoveCount", t, func(ctx convey.C) {
  52. var (
  53. c = context.Background()
  54. tp = int32(0)
  55. oid = int64(0)
  56. count = int64(0)
  57. )
  58. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  59. affect, err := testDao.IncrSubMoveCount(c, tp, oid, count)
  60. ctx.Convey("Then err should be nil.affect should not be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. ctx.So(affect, convey.ShouldNotBeNil)
  63. })
  64. })
  65. })
  66. }
  67. func TestDaoUpSubjectMCount(t *testing.T) {
  68. convey.Convey("UpSubjectMCount", t, func(ctx convey.C) {
  69. var (
  70. c = context.Background()
  71. tp = int32(0)
  72. oid = int64(0)
  73. cnt = int64(0)
  74. )
  75. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  76. affect, err := testDao.UpSubjectMCount(c, tp, oid, cnt)
  77. ctx.Convey("Then err should be nil.affect should not be nil.", func(ctx convey.C) {
  78. ctx.So(err, convey.ShouldBeNil)
  79. ctx.So(affect, convey.ShouldNotBeNil)
  80. })
  81. })
  82. })
  83. }
  84. func TestDaoUpSubjectPool(t *testing.T) {
  85. convey.Convey("UpSubjectPool", t, func(ctx convey.C) {
  86. var (
  87. c = context.Background()
  88. tp = int32(0)
  89. oid = int64(0)
  90. childpool = int32(0)
  91. )
  92. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  93. affect, err := testDao.UpSubjectPool(c, tp, oid, childpool)
  94. ctx.Convey("Then err should be nil.affect should not be nil.", func(ctx convey.C) {
  95. ctx.So(err, convey.ShouldBeNil)
  96. ctx.So(affect, convey.ShouldNotBeNil)
  97. })
  98. })
  99. })
  100. }
  101. func TestDaoIncrSubjectCount(t *testing.T) {
  102. convey.Convey("IncrSubjectCount", t, func(ctx convey.C) {
  103. var (
  104. c = context.Background()
  105. tp = int32(0)
  106. oid = int64(0)
  107. count = int64(0)
  108. )
  109. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  110. affect, err := testDao.IncrSubjectCount(c, tp, oid, count)
  111. ctx.Convey("Then err should be nil.affect should not be nil.", func(ctx convey.C) {
  112. ctx.So(err, convey.ShouldBeNil)
  113. ctx.So(affect, convey.ShouldNotBeNil)
  114. })
  115. })
  116. })
  117. }
  118. func TestDaoDMIDs(t *testing.T) {
  119. convey.Convey("DMIDs", t, func(ctx convey.C) {
  120. var (
  121. c = context.Background()
  122. tp = int32(0)
  123. oid = int64(0)
  124. ps = int64(0)
  125. pe = int64(0)
  126. limit = int64(0)
  127. pool = int32(0)
  128. )
  129. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  130. testDao.DMIDs(c, tp, oid, ps, pe, limit, pool)
  131. })
  132. })
  133. }
  134. func TestDaoIndexs(t *testing.T) {
  135. convey.Convey("Indexs", t, func(ctx convey.C) {
  136. var (
  137. c = context.Background()
  138. tp = int32(0)
  139. oid = int64(0)
  140. )
  141. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  142. testDao.Indexs(c, tp, oid)
  143. })
  144. })
  145. }
  146. func TestDaoIndexByid(t *testing.T) {
  147. convey.Convey("IndexByid", t, func(ctx convey.C) {
  148. var (
  149. c = context.Background()
  150. tp = int8(0)
  151. oid = int64(0)
  152. dmid = int64(0)
  153. )
  154. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  155. testDao.IndexByid(c, tp, oid, dmid)
  156. })
  157. })
  158. }
  159. func TestDaoIndexsByid(t *testing.T) {
  160. convey.Convey("IndexsByid", t, func(ctx convey.C) {
  161. var (
  162. c = context.Background()
  163. tp = int32(0)
  164. oid = int64(0)
  165. dmids = []int64{}
  166. )
  167. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  168. testDao.IndexsByid(c, tp, oid, dmids)
  169. })
  170. })
  171. }
  172. func TestDaoJudgeIndex(t *testing.T) {
  173. convey.Convey("JudgeIndex", t, func(ctx convey.C) {
  174. var (
  175. c = context.Background()
  176. tp = int8(0)
  177. oid = int64(0)
  178. ctime1 = xtime.Time(time.Now().Unix())
  179. ctime2 = xtime.Time(time.Now().Unix())
  180. prog1 = int32(0)
  181. prog2 = int32(0)
  182. )
  183. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  184. testDao.JudgeIndex(c, tp, oid, ctime1, ctime2, prog1, prog2)
  185. })
  186. })
  187. }
  188. func TestDaoContent(t *testing.T) {
  189. convey.Convey("Content", t, func(ctx convey.C) {
  190. var (
  191. c = context.Background()
  192. oid = int64(0)
  193. dmid = int64(0)
  194. )
  195. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  196. ct, err := testDao.Content(c, oid, dmid)
  197. ctx.Convey("Then err should be nil.ct should not be nil.", func(ctx convey.C) {
  198. ctx.So(err, convey.ShouldBeNil)
  199. ctx.So(ct, convey.ShouldNotBeNil)
  200. })
  201. })
  202. })
  203. }
  204. func TestDaoContents(t *testing.T) {
  205. convey.Convey("Contents", t, func(ctx convey.C) {
  206. var (
  207. c = context.Background()
  208. oid = int64(0)
  209. dmids = []int64{}
  210. )
  211. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  212. ctsMap, err := testDao.Contents(c, oid, dmids)
  213. ctx.Convey("Then err should be nil.ctsMap should not be nil.", func(ctx convey.C) {
  214. ctx.So(err, convey.ShouldBeNil)
  215. ctx.So(ctsMap, convey.ShouldNotBeNil)
  216. })
  217. })
  218. })
  219. }
  220. func TestDaoContentsSpecial(t *testing.T) {
  221. convey.Convey("ContentsSpecial", t, func(ctx convey.C) {
  222. var (
  223. c = context.Background()
  224. dmids = []int64{}
  225. )
  226. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  227. testDao.ContentsSpecial(c, dmids)
  228. })
  229. })
  230. }
  231. func TestDaoUpdateDMStat(t *testing.T) {
  232. convey.Convey("UpdateDMStat", t, func(ctx convey.C) {
  233. var (
  234. c = context.Background()
  235. tp = int32(0)
  236. oid = int64(0)
  237. state = int32(0)
  238. dmids = []int64{}
  239. )
  240. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  241. testDao.UpdateDMStat(c, tp, oid, state, dmids)
  242. })
  243. })
  244. }
  245. func TestDaoUpdateUserDMStat(t *testing.T) {
  246. convey.Convey("UpdateUserDMStat", t, func(ctx convey.C) {
  247. var (
  248. c = context.Background()
  249. tp = int32(0)
  250. oid = int64(0)
  251. mid = int64(0)
  252. state = int32(0)
  253. dmids = []int64{}
  254. )
  255. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  256. testDao.UpdateUserDMStat(c, tp, oid, mid, state, dmids)
  257. })
  258. })
  259. }
  260. func TestDaoUpdateDMPool(t *testing.T) {
  261. convey.Convey("UpdateDMPool", t, func(ctx convey.C) {
  262. var (
  263. c = context.Background()
  264. tp = int32(0)
  265. oid = int64(0)
  266. pool = int32(0)
  267. dmids = []int64{}
  268. )
  269. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  270. testDao.UpdateDMPool(c, tp, oid, pool, dmids)
  271. })
  272. })
  273. }
  274. func TestDaoUpdateDMAttr(t *testing.T) {
  275. convey.Convey("UpdateDMAttr", t, func(ctx convey.C) {
  276. var (
  277. c = context.Background()
  278. tp = int32(0)
  279. oid = int64(0)
  280. dmid = int64(0)
  281. attr = int32(0)
  282. )
  283. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  284. affect, err := testDao.UpdateDMAttr(c, tp, oid, dmid, attr)
  285. ctx.Convey("Then err should be nil.affect should not be nil.", func(ctx convey.C) {
  286. ctx.So(err, convey.ShouldBeNil)
  287. ctx.So(affect, convey.ShouldNotBeNil)
  288. })
  289. })
  290. })
  291. }
  292. func TestDaoDMCount(t *testing.T) {
  293. convey.Convey("DMCount", t, func(ctx convey.C) {
  294. var (
  295. c = context.Background()
  296. typ = int32(0)
  297. oid = int64(0)
  298. states = []int64{}
  299. )
  300. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  301. testDao.DMCount(c, typ, oid, states)
  302. })
  303. })
  304. }
  305. func TestDaoSpecialDmLocation(t *testing.T) {
  306. convey.Convey("SpecialDmLocation", t, func(ctx convey.C) {
  307. var (
  308. c = context.Background()
  309. tp = int32(0)
  310. oid = int64(0)
  311. )
  312. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  313. testDao.SpecialDmLocation(c, tp, oid)
  314. })
  315. })
  316. }
  317. func TestDaoSpecalDMs(t *testing.T) {
  318. convey.Convey("SpecalDMs", t, func(ctx convey.C) {
  319. var (
  320. c = context.Background()
  321. tp = int32(0)
  322. oid = int64(0)
  323. )
  324. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  325. testDao.SpecalDMs(c, tp, oid)
  326. })
  327. })
  328. }
  329. func TestDaoAddUpperConfig(t *testing.T) {
  330. convey.Convey("AddUpperConfig", t, func(ctx convey.C) {
  331. var (
  332. c = context.Background()
  333. mid = int64(0)
  334. advPermit = int8(0)
  335. )
  336. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  337. affect, err := testDao.AddUpperConfig(c, mid, advPermit)
  338. ctx.Convey("Then err should be nil.affect should not be nil.", func(ctx convey.C) {
  339. ctx.So(err, convey.ShouldBeNil)
  340. ctx.So(affect, convey.ShouldNotBeNil)
  341. })
  342. })
  343. })
  344. }
  345. func TestDaoUpperConfig(t *testing.T) {
  346. convey.Convey("UpperConfig", t, func(ctx convey.C) {
  347. var (
  348. c = context.Background()
  349. mid = int64(0)
  350. )
  351. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  352. advPermit, err := testDao.UpperConfig(c, mid)
  353. ctx.Convey("Then err should be nil.advPermit should not be nil.", func(ctx convey.C) {
  354. ctx.So(err, convey.ShouldBeNil)
  355. ctx.So(advPermit, convey.ShouldNotBeNil)
  356. })
  357. })
  358. })
  359. }