vip_test.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/admin/main/vip/model"
  7. xtime "go-common/library/time"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestDaoDelBcoinSalary(t *testing.T) {
  11. convey.Convey("DelBcoinSalary", t, func(ctx convey.C) {
  12. var (
  13. tx, _ = d.BeginTran(context.Background())
  14. mid = int64(1)
  15. month = xtime.Time(time.Now().Unix())
  16. )
  17. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  18. err := d.DelBcoinSalary(tx, mid, month)
  19. if err == nil {
  20. if err = tx.Commit(); err != nil {
  21. tx.Rollback()
  22. }
  23. } else {
  24. tx.Rollback()
  25. }
  26. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  27. ctx.So(err, convey.ShouldBeNil)
  28. })
  29. })
  30. })
  31. }
  32. func TestDaoSelVipUserInfo(t *testing.T) {
  33. convey.Convey("SelVipUserInfo", t, func(ctx convey.C) {
  34. var (
  35. c = context.Background()
  36. mid = int64(1)
  37. )
  38. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  39. r, err := d.SelVipUserInfo(c, mid)
  40. ctx.Convey("Then err should be nil.r should not be nil.", func(ctx convey.C) {
  41. ctx.So(err, convey.ShouldBeNil)
  42. ctx.So(r, convey.ShouldNotBeNil)
  43. })
  44. })
  45. })
  46. }
  47. func TestDaoUpdateVipUserInfo(t *testing.T) {
  48. convey.Convey("UpdateVipUserInfo", t, func(ctx convey.C) {
  49. var (
  50. tx, _ = d.BeginTran(context.Background())
  51. r = &model.VipUserInfo{}
  52. )
  53. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  54. a, err := d.UpdateVipUserInfo(tx, r)
  55. if err == nil {
  56. if err = tx.Commit(); err != nil {
  57. tx.Rollback()
  58. }
  59. } else {
  60. tx.Rollback()
  61. }
  62. ctx.Convey("Then err should be nil.a should not be nil.", func(ctx convey.C) {
  63. ctx.So(err, convey.ShouldBeNil)
  64. ctx.So(a, convey.ShouldNotBeNil)
  65. })
  66. })
  67. })
  68. }
  69. func TestDaoInsertVipChangeHistory(t *testing.T) {
  70. convey.Convey("InsertVipChangeHistory", t, func(ctx convey.C) {
  71. var (
  72. tx, _ = d.BeginTran(context.Background())
  73. r = &model.VipChangeHistory{}
  74. )
  75. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  76. id, err := d.InsertVipChangeHistory(tx, r)
  77. if err == nil {
  78. if err = tx.Commit(); err != nil {
  79. tx.Rollback()
  80. }
  81. } else {
  82. tx.Rollback()
  83. }
  84. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  85. ctx.So(err, convey.ShouldBeNil)
  86. ctx.So(id, convey.ShouldNotBeNil)
  87. })
  88. })
  89. })
  90. }