up_account_test.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package income
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestIncomeUpAccountCount(t *testing.T) {
  8. convey.Convey("UpAccountCount", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. query = ""
  12. isDeleted = int(0)
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. total, err := d.UpAccountCount(c, query, isDeleted)
  16. ctx.Convey("Then err should be nil.total should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(total, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestIncomeListUpAccount(t *testing.T) {
  24. convey.Convey("ListUpAccount", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. query = ""
  28. isDeleted = int(0)
  29. from = int(0)
  30. limit = int(100)
  31. )
  32. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  33. ups, err := d.ListUpAccount(c, query, isDeleted, from, limit)
  34. ctx.Convey("Then err should be nil.ups should not be nil.", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. ctx.So(ups, convey.ShouldNotBeNil)
  37. })
  38. })
  39. })
  40. }
  41. func TestIncomeGetUpAccount(t *testing.T) {
  42. convey.Convey("GetUpAccount", t, func(ctx convey.C) {
  43. var (
  44. c = context.Background()
  45. mid = int64(1001)
  46. )
  47. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  48. Exec(c, "INSERT INTO up_account(mid) VALUES(1001)")
  49. up, err := d.GetUpAccount(c, mid)
  50. ctx.Convey("Then err should be nil.up should not be nil.", func(ctx convey.C) {
  51. ctx.So(err, convey.ShouldBeNil)
  52. ctx.So(up, convey.ShouldNotBeNil)
  53. })
  54. })
  55. })
  56. }
  57. func TestIncomeTxBreachUpAccount(t *testing.T) {
  58. convey.Convey("TxBreachUpAccount", t, func(ctx convey.C) {
  59. var (
  60. tx, _ = d.BeginTran(context.Background())
  61. total = int64(0)
  62. unwithdraw = int64(0)
  63. mid = int64(1001)
  64. newVersion = int64(0)
  65. oldVersion = int64(0)
  66. )
  67. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  68. rows, err := d.TxBreachUpAccount(tx, total, unwithdraw, mid, newVersion, oldVersion)
  69. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  70. ctx.So(err, convey.ShouldBeNil)
  71. ctx.So(rows, convey.ShouldNotBeNil)
  72. })
  73. })
  74. })
  75. }