task_oper_history_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoAvgUtimeByUID(t *testing.T) {
  9. var (
  10. c = context.TODO()
  11. uid = int64(421)
  12. stime = time.Now()
  13. etime = time.Now()
  14. )
  15. convey.Convey("AvgUtimeByUID", t, func(ctx convey.C) {
  16. utime, err := d.AvgUtimeByUID(c, uid, stime, etime)
  17. ctx.Convey("Then err should be nil.utime should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(utime, convey.ShouldNotBeNil)
  20. })
  21. })
  22. }
  23. func TestDaoSumDurationByUID(t *testing.T) {
  24. var (
  25. c = context.TODO()
  26. uid = int64(421)
  27. stime = time.Now()
  28. etime = time.Now()
  29. )
  30. convey.Convey("SumDurationByUID", t, func(ctx convey.C) {
  31. duration, err := d.SumDurationByUID(c, uid, stime, etime)
  32. ctx.Convey("Then err should be nil.duration should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. ctx.So(duration, convey.ShouldNotBeNil)
  35. })
  36. })
  37. }
  38. func TestDaoActionCountByUID(t *testing.T) {
  39. var (
  40. c = context.TODO()
  41. uid = int64(421)
  42. stime = time.Now()
  43. etime = time.Now()
  44. )
  45. convey.Convey("ActionCountByUID", t, func(ctx convey.C) {
  46. mapAction, err := d.ActionCountByUID(c, uid, stime, etime)
  47. ctx.Convey("Then err should be nil.mapAction should not be nil.", func(ctx convey.C) {
  48. ctx.So(err, convey.ShouldBeNil)
  49. ctx.So(mapAction, convey.ShouldNotBeNil)
  50. })
  51. })
  52. }
  53. func TestDaoPassCountByUID(t *testing.T) {
  54. var (
  55. c = context.TODO()
  56. uid = int64(421)
  57. stime = time.Now()
  58. etime = time.Now()
  59. )
  60. convey.Convey("PassCountByUID", t, func(ctx convey.C) {
  61. count, err := d.PassCountByUID(c, uid, stime, etime)
  62. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  63. ctx.So(err, convey.ShouldBeNil)
  64. ctx.So(count, convey.ShouldNotBeNil)
  65. })
  66. })
  67. }
  68. func TestDaoSubjectCountByUID(t *testing.T) {
  69. var (
  70. c = context.TODO()
  71. uid = int64(421)
  72. stime = time.Now()
  73. etime = time.Now()
  74. )
  75. convey.Convey("SubjectCountByUID", t, func(ctx convey.C) {
  76. count, err := d.SubjectCountByUID(c, uid, stime, etime)
  77. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  78. ctx.So(err, convey.ShouldBeNil)
  79. ctx.So(count, convey.ShouldNotBeNil)
  80. })
  81. })
  82. }
  83. func TestDaoActiveUids(t *testing.T) {
  84. var (
  85. c = context.TODO()
  86. stime = time.Now().AddDate(-1, 0, 0)
  87. etime = time.Now()
  88. )
  89. convey.Convey("ActiveUids", t, func(ctx convey.C) {
  90. _, err := d.ActiveUids(c, stime, etime)
  91. ctx.Convey("Then err should be nil.uids should not be nil.", func(ctx convey.C) {
  92. ctx.So(err, convey.ShouldBeNil)
  93. })
  94. })
  95. }