mysql_test.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/history/model"
  5. "testing"
  6. "time"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoBusinesses(t *testing.T) {
  10. convey.Convey("Businesses", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. )
  14. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  15. res, err := d.Businesses(c)
  16. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(res, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoDeleteHistories(t *testing.T) {
  24. convey.Convey("DeleteHistories", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. bid = int64(14771787)
  28. beginTime = time.Now()
  29. endTime = time.Now()
  30. )
  31. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  32. rows, err := d.DeleteHistories(c, bid, beginTime, endTime)
  33. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(rows, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDaoAddHistories(t *testing.T) {
  41. convey.Convey("AddHistories", t, func(ctx convey.C) {
  42. var (
  43. c = context.Background()
  44. hs = []*model.History{}
  45. )
  46. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  47. err := d.AddHistories(c, hs)
  48. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  49. ctx.So(err, convey.ShouldBeNil)
  50. })
  51. })
  52. })
  53. }
  54. func TestDaoDeleteUserHistories(t *testing.T) {
  55. convey.Convey("DeleteUserHistories", t, func(ctx convey.C) {
  56. var (
  57. c = context.Background()
  58. mid = int64(14771787)
  59. bid = int64(14771787)
  60. no = time.Now()
  61. )
  62. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  63. rows, err := d.DeleteUserHistories(c, mid, bid, no)
  64. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  65. ctx.So(err, convey.ShouldBeNil)
  66. ctx.So(rows, convey.ShouldNotBeNil)
  67. })
  68. })
  69. })
  70. }
  71. func TestDaoUserHistories(t *testing.T) {
  72. convey.Convey("UserHistories", t, func(ctx convey.C) {
  73. var (
  74. c = context.Background()
  75. mid = int64(14771787)
  76. businessID = int64(3)
  77. )
  78. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  79. _, err := d.UserHistories(c, mid, businessID)
  80. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  81. ctx.So(err, convey.ShouldBeNil)
  82. })
  83. })
  84. })
  85. }
  86. func TestDaoEarlyHistory(t *testing.T) {
  87. convey.Convey("EarlyHistory", t, func(ctx convey.C) {
  88. var (
  89. c = context.Background()
  90. businessID = int64(3)
  91. )
  92. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  93. res, err := d.EarlyHistory(c, businessID)
  94. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  95. ctx.So(err, convey.ShouldBeNil)
  96. ctx.So(res, convey.ShouldNotBeNil)
  97. })
  98. })
  99. })
  100. }