up_test.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/admin/main/growup/model"
  7. xtime "go-common/library/time"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestDaoInsertWhitelist(t *testing.T) {
  11. convey.Convey("InsertWhitelist", t, func(ctx convey.C) {
  12. var (
  13. c = context.Background()
  14. mid = int64(1001)
  15. typ = int(0)
  16. )
  17. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  18. Exec(c, "DELETE FROM up_white_list where mid = 1001")
  19. rows, err := d.InsertWhitelist(c, mid, typ)
  20. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  21. ctx.So(err, convey.ShouldBeNil)
  22. ctx.So(rows, convey.ShouldNotBeNil)
  23. })
  24. })
  25. })
  26. }
  27. func TestDaoPendings(t *testing.T) {
  28. convey.Convey("Pendings", t, func(ctx convey.C) {
  29. var (
  30. c = context.Background()
  31. mids = []int64{1001}
  32. table = "up_info_video"
  33. )
  34. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  35. Exec(c, "INSERT INTO up_info_video(mid, account_state) VALUES(1001, 2) ON DUPLICATE KEY UPDATE account_state = 2")
  36. ms, err := d.Pendings(c, mids, table)
  37. ctx.Convey("Then err should be nil.ms should not be nil.", func(ctx convey.C) {
  38. ctx.So(err, convey.ShouldBeNil)
  39. ctx.So(ms, convey.ShouldNotBeNil)
  40. })
  41. })
  42. })
  43. }
  44. func TestDaoUnusualUps(t *testing.T) {
  45. convey.Convey("UnusualUps", t, func(ctx convey.C) {
  46. var (
  47. c = context.Background()
  48. mids = []int64{1002}
  49. table = "up_info_video"
  50. )
  51. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  52. Exec(c, "INSERT INTO up_info_video(mid, account_state) VALUES(1002, 5) ON DUPLICATE KEY UPDATE account_state = 5")
  53. ms, err := d.UnusualUps(c, mids, table)
  54. ctx.Convey("Then err should be nil.ms should not be nil.", func(ctx convey.C) {
  55. ctx.So(err, convey.ShouldBeNil)
  56. ctx.So(ms, convey.ShouldNotBeNil)
  57. })
  58. })
  59. })
  60. }
  61. func TestDaoInsertUpVideo(t *testing.T) {
  62. convey.Convey("InsertUpVideo", t, func(ctx convey.C) {
  63. var (
  64. c = context.Background()
  65. now = xtime.Time(time.Now().Unix())
  66. v = &model.UpInfo{
  67. MID: 1003,
  68. Nickname: "aa",
  69. AccountType: 1,
  70. AccountState: 1,
  71. OriginalArchiveCount: 1,
  72. MainCategory: 1,
  73. Fans: 1,
  74. SignType: 1,
  75. Reason: "",
  76. ApplyAt: now,
  77. SignedAt: now,
  78. RejectAt: now,
  79. ForbidAt: now,
  80. QuitAt: now,
  81. DismissAt: now,
  82. ExpiredIn: now,
  83. }
  84. )
  85. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  86. Exec(c, "DELETE FROM up_info_video WHERE mid = 1003")
  87. rows, err := d.InsertUpVideo(c, v)
  88. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  89. ctx.So(err, convey.ShouldBeNil)
  90. ctx.So(rows, convey.ShouldNotBeNil)
  91. })
  92. })
  93. })
  94. }
  95. func TestDaoInsertUpColumn(t *testing.T) {
  96. convey.Convey("InsertUpColumn", t, func(ctx convey.C) {
  97. var (
  98. c = context.Background()
  99. up = &model.UpInfo{
  100. MID: 1004,
  101. Nickname: "aa",
  102. }
  103. )
  104. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  105. Exec(c, "DELETE FROM up_info_column WHERE mid = 1004")
  106. rows, err := d.InsertUpColumn(c, up)
  107. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  108. ctx.So(err, convey.ShouldBeNil)
  109. ctx.So(rows, convey.ShouldNotBeNil)
  110. })
  111. })
  112. })
  113. }
  114. func TestDaoInsertBgmUpInfo(t *testing.T) {
  115. convey.Convey("InsertBgmUpInfo", t, func(ctx convey.C) {
  116. var (
  117. c = context.Background()
  118. m = &model.UpInfo{
  119. MID: 1005,
  120. AccountState: 3,
  121. }
  122. )
  123. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  124. Exec(c, "DELETE FROM up_info_bgm WHERE mid = 1005")
  125. rows, err := d.InsertBgmUpInfo(c, m)
  126. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  127. ctx.So(err, convey.ShouldBeNil)
  128. ctx.So(rows, convey.ShouldNotBeNil)
  129. })
  130. })
  131. })
  132. }
  133. func TestDaoCategoryInfo(t *testing.T) {
  134. convey.Convey("CategoryInfo", t, func(ctx convey.C) {
  135. var (
  136. c = context.Background()
  137. mid = int64(1001)
  138. )
  139. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  140. nickname, categoryID, err := d.CategoryInfo(c, mid)
  141. Exec(c, "INSERT INTO up_category_info(mid,nick_name) VALUES(1001, 'tt')")
  142. ctx.Convey("Then err should be nil.nickname,categoryID should not be nil.", func(ctx convey.C) {
  143. ctx.So(err, convey.ShouldBeNil)
  144. ctx.So(categoryID, convey.ShouldNotBeNil)
  145. ctx.So(nickname, convey.ShouldNotBeNil)
  146. })
  147. })
  148. })
  149. }
  150. func TestDaoStat(t *testing.T) {
  151. convey.Convey("Stat", t, func(ctx convey.C) {
  152. var (
  153. c = context.Background()
  154. mid = int64(1001)
  155. )
  156. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  157. Exec(c, "INSERT INTO up_base_statistics(mid, fans, avs) VALUES(1001, 10, 10)")
  158. fans, avs, err := d.Stat(c, mid)
  159. ctx.Convey("Then err should be nil.fans,avs should not be nil.", func(ctx convey.C) {
  160. ctx.So(err, convey.ShouldBeNil)
  161. ctx.So(avs, convey.ShouldNotBeNil)
  162. ctx.So(fans, convey.ShouldNotBeNil)
  163. })
  164. })
  165. })
  166. }
  167. func TestDaoUpsCount(t *testing.T) {
  168. convey.Convey("UpsCount", t, func(ctx convey.C) {
  169. var (
  170. c = context.Background()
  171. table = "up_info_video"
  172. query = "id > 0"
  173. )
  174. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  175. Exec(c, "INSERT INTO up_info_video(mid, account_state) VALUES(1006, 3)")
  176. count, err := d.UpsCount(c, table, query)
  177. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  178. ctx.So(err, convey.ShouldBeNil)
  179. ctx.So(count, convey.ShouldNotBeNil)
  180. })
  181. })
  182. })
  183. }
  184. func TestDaoUpsVideoInfo(t *testing.T) {
  185. convey.Convey("UpsVideoInfo", t, func(ctx convey.C) {
  186. var (
  187. c = context.Background()
  188. query = "id > 0"
  189. )
  190. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  191. ups, err := d.UpsVideoInfo(c, query)
  192. ctx.Convey("Then err should be nil.ups should not be nil.", func(ctx convey.C) {
  193. ctx.So(err, convey.ShouldBeNil)
  194. ctx.So(ups, convey.ShouldNotBeNil)
  195. })
  196. })
  197. })
  198. }
  199. func TestDaoUpsColumnInfo(t *testing.T) {
  200. convey.Convey("UpsColumnInfo", t, func(ctx convey.C) {
  201. var (
  202. c = context.Background()
  203. query = "id > 0"
  204. )
  205. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  206. ups, err := d.UpsColumnInfo(c, query)
  207. ctx.Convey("Then err should be nil.ups should not be nil.", func(ctx convey.C) {
  208. ctx.So(err, convey.ShouldBeNil)
  209. ctx.So(ups, convey.ShouldNotBeNil)
  210. })
  211. })
  212. })
  213. }
  214. func TestDaoUpsBgmInfo(t *testing.T) {
  215. convey.Convey("UpsBgmInfo", t, func(ctx convey.C) {
  216. var (
  217. c = context.Background()
  218. query = "id > 0"
  219. )
  220. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  221. ups, err := d.UpsBgmInfo(c, query)
  222. ctx.Convey("Then err should be nil.ups should not be nil.", func(ctx convey.C) {
  223. ctx.So(err, convey.ShouldBeNil)
  224. ctx.So(ups, convey.ShouldNotBeNil)
  225. })
  226. })
  227. })
  228. }
  229. func TestDaoReject(t *testing.T) {
  230. convey.Convey("Reject", t, func(ctx convey.C) {
  231. var (
  232. c = context.Background()
  233. table = "up_info_video"
  234. state = int(6)
  235. reason = "test"
  236. rejectAt = xtime.Time(time.Now().Unix())
  237. expiredIn = xtime.Time(time.Now().Unix())
  238. mids = []int64{1007}
  239. )
  240. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  241. Exec(c, "INSERT INTO up_info_video(mid, account_state) VALUES(1007, 3) ON DUPLICATE KEY UPDATE account_state = 3")
  242. rows, err := d.Reject(c, table, state, reason, rejectAt, expiredIn, mids)
  243. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  244. ctx.So(err, convey.ShouldBeNil)
  245. ctx.So(rows, convey.ShouldNotBeNil)
  246. })
  247. })
  248. })
  249. }
  250. func TestDaoPass(t *testing.T) {
  251. convey.Convey("Pass", t, func(ctx convey.C) {
  252. var (
  253. c = context.Background()
  254. table = "up_info_video"
  255. state = int(3)
  256. signedAt = xtime.Time(time.Now().Unix())
  257. mids = []int64{1008}
  258. )
  259. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  260. Exec(c, "INSERT INTO up_info_video(mid, account_state) VALUES(1008, 2) ON DUPLICATE KEY UPDATE account_state = 2")
  261. rows, err := d.Pass(c, table, state, signedAt, mids)
  262. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  263. ctx.So(err, convey.ShouldBeNil)
  264. ctx.So(rows, convey.ShouldNotBeNil)
  265. })
  266. })
  267. })
  268. }
  269. func TestDaoDismiss(t *testing.T) {
  270. convey.Convey("Dismiss", t, func(ctx convey.C) {
  271. var (
  272. c = context.Background()
  273. table = "up_info_video"
  274. newState = int(6)
  275. oldState = int(3)
  276. reason = "test"
  277. dismissAt = xtime.Time(time.Now().Unix())
  278. quitAt = xtime.Time(time.Now().Unix())
  279. mid = int64(1008)
  280. )
  281. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  282. Exec(c, "INSERT INTO up_info_video(mid, account_state) VALUES(1008, 3) ON DUPLICATE KEY UPDATE account_state = 3")
  283. rows, err := d.Dismiss(c, table, newState, oldState, reason, dismissAt, quitAt, mid)
  284. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  285. ctx.So(err, convey.ShouldBeNil)
  286. ctx.So(rows, convey.ShouldNotBeNil)
  287. })
  288. })
  289. })
  290. }
  291. func TestDaoTxDismiss(t *testing.T) {
  292. convey.Convey("TxDismiss", t, func(ctx convey.C) {
  293. var (
  294. c = context.Background()
  295. tx, _ = d.BeginTran(c)
  296. table = "up_info_video"
  297. newState = int(6)
  298. oldState = int(3)
  299. reason = ""
  300. dismissAt = xtime.Time(time.Now().Unix())
  301. quitAt = xtime.Time(time.Now().Unix())
  302. mid = int64(1008)
  303. )
  304. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  305. defer tx.Commit()
  306. Exec(c, "INSERT INTO up_info_video(mid, account_state) VALUES(1008, 3) ON DUPLICATE KEY UPDATE account_state = 3")
  307. rows, err := d.TxDismiss(tx, table, newState, oldState, reason, dismissAt, quitAt, mid)
  308. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  309. ctx.So(err, convey.ShouldBeNil)
  310. ctx.So(rows, convey.ShouldNotBeNil)
  311. })
  312. })
  313. })
  314. }
  315. func TestDaoForbid(t *testing.T) {
  316. convey.Convey("Forbid", t, func(ctx convey.C) {
  317. var (
  318. c = context.Background()
  319. table = "up_info_video"
  320. newState = int(7)
  321. oldState = int(3)
  322. reason = ""
  323. forbidAt = xtime.Time(time.Now().Unix())
  324. expiredIn = xtime.Time(time.Now().Unix())
  325. mid = int64(1008)
  326. )
  327. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  328. Exec(c, "INSERT INTO up_info_video(mid, account_state) VALUES(1008, 3) ON DUPLICATE KEY UPDATE account_state = 3")
  329. rows, err := d.Forbid(c, table, newState, oldState, reason, forbidAt, expiredIn, mid)
  330. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  331. ctx.So(err, convey.ShouldBeNil)
  332. ctx.So(rows, convey.ShouldNotBeNil)
  333. })
  334. })
  335. })
  336. }
  337. func TestDaoTxForbid(t *testing.T) {
  338. convey.Convey("TxForbid", t, func(ctx convey.C) {
  339. var (
  340. c = context.Background()
  341. tx, _ = d.BeginTran(c)
  342. table = "up_info_video"
  343. newState = int(6)
  344. oldState = int(3)
  345. reason = "test"
  346. forbidAt = xtime.Time(time.Now().Unix())
  347. expiredIn = xtime.Time(time.Now().Unix())
  348. mid = int64(1008)
  349. )
  350. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  351. defer tx.Commit()
  352. Exec(c, "INSERT INTO up_info_video(mid, account_state) VALUES(1008, 3) ON DUPLICATE KEY UPDATE account_state = 3")
  353. rows, err := d.TxForbid(tx, table, newState, oldState, reason, forbidAt, expiredIn, mid)
  354. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  355. ctx.So(err, convey.ShouldBeNil)
  356. ctx.So(rows, convey.ShouldNotBeNil)
  357. })
  358. })
  359. })
  360. }
  361. func TestDaoUpdateAccountState(t *testing.T) {
  362. convey.Convey("UpdateAccountState", t, func(ctx convey.C) {
  363. var (
  364. c = context.Background()
  365. table = "up_info_video"
  366. state = int(4)
  367. mid = int64(1008)
  368. )
  369. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  370. Exec(c, "INSERT INTO up_info_video(mid, account_state) VALUES(1008, 3) ON DUPLICATE KEY UPDATE account_state = 3")
  371. rows, err := d.UpdateAccountState(c, table, state, mid)
  372. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  373. ctx.So(err, convey.ShouldBeNil)
  374. ctx.So(rows, convey.ShouldNotBeNil)
  375. })
  376. })
  377. })
  378. }
  379. func TestDaoDelUpInfo(t *testing.T) {
  380. convey.Convey("DelUpInfo", t, func(ctx convey.C) {
  381. var (
  382. c = context.Background()
  383. table = "up_info_video"
  384. mid = int64(1008)
  385. )
  386. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  387. Exec(c, "INSERT INTO up_info_video(mid, is_deleted) VALUES(1008, 0) ON DUPLICATE KEY UPDATE is_deleted = 0")
  388. rows, err := d.DelUpInfo(c, table, mid)
  389. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  390. ctx.So(err, convey.ShouldBeNil)
  391. ctx.So(rows, convey.ShouldNotBeNil)
  392. })
  393. })
  394. })
  395. }
  396. func TestDaoRecUpInfo(t *testing.T) {
  397. convey.Convey("RecUpInfo", t, func(ctx convey.C) {
  398. var (
  399. c = context.Background()
  400. table = "up_info_video"
  401. mid = int64(1008)
  402. )
  403. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  404. Exec(c, "INSERT INTO up_info_video(mid, is_deleted) VALUES(1008, 1) ON DUPLICATE KEY UPDATE is_deleted = 1")
  405. rows, err := d.RecUpInfo(c, table, mid)
  406. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  407. ctx.So(err, convey.ShouldBeNil)
  408. ctx.So(rows, convey.ShouldNotBeNil)
  409. })
  410. })
  411. })
  412. }
  413. func TestDaoupdateUpInfoDel(t *testing.T) {
  414. convey.Convey("updateUpInfoDel", t, func(ctx convey.C) {
  415. var (
  416. c = context.Background()
  417. table = "up_info_video"
  418. mid = int64(1008)
  419. isDeleted = int(0)
  420. )
  421. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  422. Exec(c, "INSERT INTO up_info_video(mid, is_deleted) VALUES(1008, 1) ON DUPLICATE KEY UPDATE is_deleted = 1")
  423. rows, err := d.updateUpInfoDel(c, table, mid, isDeleted)
  424. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  425. ctx.So(err, convey.ShouldBeNil)
  426. ctx.So(rows, convey.ShouldNotBeNil)
  427. })
  428. })
  429. })
  430. }
  431. func TestDaoDelUpAccount(t *testing.T) {
  432. convey.Convey("DelUpAccount", t, func(ctx convey.C) {
  433. var (
  434. c = context.Background()
  435. mid = int64(1008)
  436. )
  437. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  438. Exec(c, "INSERT INTO up_account(mid, is_deleted) VALUES(1008, 0) ON DUPLICATE KEY UPDATE is_deleted = 0")
  439. rows, err := d.DelUpAccount(c, mid)
  440. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  441. ctx.So(err, convey.ShouldBeNil)
  442. ctx.So(rows, convey.ShouldNotBeNil)
  443. })
  444. })
  445. })
  446. }
  447. func TestDaoDelCreditRecord(t *testing.T) {
  448. convey.Convey("DelCreditRecord", t, func(ctx convey.C) {
  449. var (
  450. c = context.Background()
  451. id = int64(1000)
  452. )
  453. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  454. Exec(c, "INSERT INTO credit_score_record(id, is_deleted) VALEUS(1000, 0) ON DUPLICATE KEY UPDATE is_deleted = 0")
  455. rows, err := d.DelCreditRecord(c, id)
  456. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  457. ctx.So(err, convey.ShouldBeNil)
  458. ctx.So(rows, convey.ShouldNotBeNil)
  459. })
  460. })
  461. })
  462. }
  463. func TestDaoTxDelCreditRecord(t *testing.T) {
  464. convey.Convey("TxDelCreditRecord", t, func(ctx convey.C) {
  465. var (
  466. c = context.Background()
  467. tx, _ = d.BeginTran(c)
  468. id = int64(1000)
  469. )
  470. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  471. defer tx.Commit()
  472. Exec(c, "INSERT INTO credit_score_record(id, is_deleted) VALEUS(1000, 0) ON DUPLICATE KEY UPDATE is_deleted = 0")
  473. rows, err := d.TxDelCreditRecord(tx, id)
  474. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  475. ctx.So(err, convey.ShouldBeNil)
  476. ctx.So(rows, convey.ShouldNotBeNil)
  477. })
  478. })
  479. })
  480. }
  481. func TestDaoUpInfo(t *testing.T) {
  482. convey.Convey("UpInfo", t, func(ctx convey.C) {
  483. var (
  484. c = context.Background()
  485. mid = int64(1008)
  486. state = int64(3)
  487. )
  488. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  489. Exec(c, "INSERT INTO up_info_video(mid, account_state, is_deleted) VALUES(1008, 3, 0) ON DUPLICATE KEY UPDATE account_state = 3, is_deleted = 0")
  490. info, err := d.UpInfo(c, mid, state)
  491. ctx.Convey("Then err should be nil.info should not be nil.", func(ctx convey.C) {
  492. ctx.So(err, convey.ShouldBeNil)
  493. ctx.So(info, convey.ShouldNotBeNil)
  494. })
  495. })
  496. })
  497. }
  498. func TestDaoGetUpInfoByState(t *testing.T) {
  499. convey.Convey("GetUpInfoByState", t, func(ctx convey.C) {
  500. var (
  501. c = context.Background()
  502. table = "up_info_video"
  503. mids = []int64{1008}
  504. state = int(3)
  505. )
  506. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  507. info, err := d.GetUpInfoByState(c, table, mids, state)
  508. ctx.Convey("Then err should be nil.info should not be nil.", func(ctx convey.C) {
  509. ctx.So(err, convey.ShouldBeNil)
  510. ctx.So(info, convey.ShouldNotBeNil)
  511. })
  512. })
  513. })
  514. }
  515. func TestDaoGetUpState(t *testing.T) {
  516. convey.Convey("GetUpState", t, func(ctx convey.C) {
  517. var (
  518. c = context.Background()
  519. table = "up_info_video"
  520. mid = int64(1008)
  521. )
  522. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  523. state, err := d.GetUpState(c, table, mid)
  524. ctx.Convey("Then err should be nil.state should not be nil.", func(ctx convey.C) {
  525. ctx.So(err, convey.ShouldBeNil)
  526. ctx.So(state, convey.ShouldNotBeNil)
  527. })
  528. })
  529. })
  530. }
  531. func TestDaoBGMCount(t *testing.T) {
  532. convey.Convey("BGMCount", t, func(ctx convey.C) {
  533. var (
  534. c = context.Background()
  535. mid = int64(1008)
  536. )
  537. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  538. Exec(c, "INSERT INTO background_music(sid, mid) VALUES(100, 1008)")
  539. count, err := d.BGMCount(c, mid)
  540. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  541. ctx.So(err, convey.ShouldBeNil)
  542. ctx.So(count, convey.ShouldNotBeNil)
  543. })
  544. })
  545. })
  546. }