up_info_video_test.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package income
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestIncomeGetUpInfoNickname(t *testing.T) {
  8. convey.Convey("GetUpInfoNickname", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. mids = []int64{1993}
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. Exec(c, "INSERT INTO up_info_video(mid, account_state) VALUES(1993, 3)")
  15. upInfo, err := d.GetUpInfoNickname(c, mids)
  16. ctx.Convey("Then err should be nil.upInfo should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(upInfo, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestIncomeGetUpInfoNicknameByMID(t *testing.T) {
  24. convey.Convey("GetUpInfoNicknameByMID", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. mid = int64(1993)
  28. table = "up_info_video"
  29. )
  30. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  31. nickname, err := d.GetUpInfoNicknameByMID(c, mid, table)
  32. ctx.Convey("Then err should be nil.nickname should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. ctx.So(nickname, convey.ShouldNotBeNil)
  35. })
  36. })
  37. })
  38. }
  39. func TestIncomeTxUpdateUpInfoScore(t *testing.T) {
  40. convey.Convey("TxUpdateUpInfoScore", t, func(ctx convey.C) {
  41. var (
  42. tx, _ = d.BeginTran(context.Background())
  43. table = "up_info_video"
  44. score = int(5)
  45. mid = int64(1993)
  46. )
  47. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  48. defer tx.Commit()
  49. rows, err := d.TxUpdateUpInfoScore(tx, table, score, mid)
  50. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  51. ctx.So(err, convey.ShouldBeNil)
  52. ctx.So(rows, convey.ShouldNotBeNil)
  53. })
  54. })
  55. })
  56. }