activity_test.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoGetCActivities(t *testing.T) {
  8. convey.Convey("GetCActivities", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. )
  12. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  13. acs, err := d.GetCActivities(c)
  14. ctx.Convey("Then err should be nil.acs should not be nil.", func(ctx convey.C) {
  15. ctx.So(err, convey.ShouldBeNil)
  16. ctx.So(acs, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestDaoListUpActivity(t *testing.T) {
  22. convey.Convey("ListUpActivity", t, func(ctx convey.C) {
  23. var (
  24. c = context.Background()
  25. id = int64(10)
  26. )
  27. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  28. ups, err := d.ListUpActivity(c, id)
  29. ctx.Convey("Then err should be nil.ups should not be nil.", func(ctx convey.C) {
  30. ctx.So(err, convey.ShouldBeNil)
  31. ctx.So(ups, convey.ShouldNotBeNil)
  32. })
  33. })
  34. })
  35. }
  36. func TestDaoGetActivityBonus(t *testing.T) {
  37. convey.Convey("GetActivityBonus", t, func(ctx convey.C) {
  38. var (
  39. c = context.Background()
  40. id = int64(10)
  41. )
  42. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  43. actBonus, err := d.GetActivityBonus(c, id)
  44. ctx.Convey("Then err should be nil.actBonus should not be nil.", func(ctx convey.C) {
  45. ctx.So(err, convey.ShouldBeNil)
  46. ctx.So(actBonus, convey.ShouldNotBeNil)
  47. })
  48. })
  49. })
  50. }
  51. func TestDaoGetAvUploadByMID(t *testing.T) {
  52. convey.Convey("GetAvUploadByMID", t, func(ctx convey.C) {
  53. var (
  54. c = context.Background()
  55. id = int64(10)
  56. limit = int(100)
  57. )
  58. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  59. avs, err := d.GetAvUploadByMID(c, id, limit)
  60. ctx.Convey("Then err should be nil.avs should not be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. ctx.So(avs, convey.ShouldNotBeNil)
  63. })
  64. })
  65. })
  66. }
  67. func TestDaoGetArchiveInfo(t *testing.T) {
  68. convey.Convey("GetArchiveInfo", t, func(ctx convey.C) {
  69. var (
  70. c = context.Background()
  71. activityID = int64(10)
  72. id = int64(100)
  73. limit = int(200)
  74. )
  75. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  76. avs, err := d.GetArchiveInfo(c, activityID, id, limit)
  77. ctx.Convey("Then err should be nil.avs should not be nil.", func(ctx convey.C) {
  78. ctx.So(err, convey.ShouldNotBeNil)
  79. ctx.So(avs, convey.ShouldNotBeNil)
  80. })
  81. })
  82. })
  83. }
  84. func TestDaoUpdateUpActivityState(t *testing.T) {
  85. convey.Convey("UpdateUpActivityState", t, func(ctx convey.C) {
  86. var (
  87. c = context.Background()
  88. id = int64(100)
  89. oldState = int(10)
  90. newState = int(200)
  91. )
  92. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  93. count, err := d.UpdateUpActivityState(c, id, oldState, newState)
  94. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  95. ctx.So(err, convey.ShouldBeNil)
  96. ctx.So(count, convey.ShouldNotBeNil)
  97. })
  98. })
  99. })
  100. }
  101. func TestDaoInsertUpActivityBatch(t *testing.T) {
  102. convey.Convey("InsertUpActivityBatch", t, func(ctx convey.C) {
  103. var (
  104. c = context.Background()
  105. vals = "(10, 'test', 100, 90, 100, 1, 1000, 3, '2018-06-23')"
  106. )
  107. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  108. count, err := d.InsertUpActivityBatch(c, vals)
  109. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  110. ctx.So(err, convey.ShouldBeNil)
  111. ctx.So(count, convey.ShouldNotBeNil)
  112. })
  113. })
  114. })
  115. }