banner_test.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoTotalBannerCount(t *testing.T) {
  8. convey.Convey("TotalBannerCount", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. )
  12. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  13. count, err := d.TotalBannerCount(c)
  14. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  15. ctx.So(err, convey.ShouldBeNil)
  16. ctx.So(count, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestDaoDupEditBanner(t *testing.T) {
  22. convey.Convey("DupEditBanner", t, func(ctx convey.C) {
  23. var (
  24. c = context.Background()
  25. startAt = int64(0)
  26. endAt = int64(0)
  27. now = int64(0)
  28. id = int64(0)
  29. )
  30. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  31. dup, err := d.DupEditBanner(c, startAt, endAt, now, id)
  32. ctx.Convey("Then err should be nil.dup should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. ctx.So(dup, convey.ShouldNotBeNil)
  35. })
  36. })
  37. })
  38. }
  39. func TestDaoDupBanner(t *testing.T) {
  40. convey.Convey("DupBanner", t, func(ctx convey.C) {
  41. var (
  42. c = context.Background()
  43. startAt = int64(0)
  44. endAt = int64(0)
  45. now = int64(0)
  46. )
  47. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  48. dup, err := d.DupBanner(c, startAt, endAt, now)
  49. ctx.Convey("Then err should be nil.dup should not be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. ctx.So(dup, convey.ShouldNotBeNil)
  52. })
  53. })
  54. })
  55. }
  56. func TestDaoInsertBanner(t *testing.T) {
  57. convey.Convey("InsertBanner", t, func(ctx convey.C) {
  58. var (
  59. c = context.Background()
  60. image = ""
  61. link = ""
  62. startAt = int64(0)
  63. endAt = int64(0)
  64. )
  65. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  66. rows, err := d.InsertBanner(c, image, link, startAt, endAt)
  67. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  68. ctx.So(err, convey.ShouldBeNil)
  69. ctx.So(rows, convey.ShouldNotBeNil)
  70. })
  71. })
  72. })
  73. }
  74. func TestDaoBanners(t *testing.T) {
  75. convey.Convey("Banners", t, func(ctx convey.C) {
  76. var (
  77. c = context.Background()
  78. offset = int64(0)
  79. limit = int64(10)
  80. )
  81. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  82. _, err := d.Banners(c, offset, limit)
  83. ctx.Convey("Then err should be nil.bs should not be nil.", func(ctx convey.C) {
  84. ctx.So(err, convey.ShouldBeNil)
  85. })
  86. })
  87. })
  88. }
  89. func TestDaoUpdateBanner(t *testing.T) {
  90. convey.Convey("UpdateBanner", t, func(ctx convey.C) {
  91. var (
  92. c = context.Background()
  93. image = ""
  94. link = ""
  95. startAt = int64(0)
  96. endAt = int64(0)
  97. id = int64(0)
  98. )
  99. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  100. rows, err := d.UpdateBanner(c, image, link, startAt, endAt, id)
  101. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  102. ctx.So(err, convey.ShouldBeNil)
  103. ctx.So(rows, convey.ShouldNotBeNil)
  104. })
  105. })
  106. })
  107. }
  108. func TestDaoUpdateBannerEndAt(t *testing.T) {
  109. convey.Convey("UpdateBannerEndAt", t, func(ctx convey.C) {
  110. var (
  111. c = context.Background()
  112. endAt = int64(0)
  113. id = int64(0)
  114. )
  115. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  116. rows, err := d.UpdateBannerEndAt(c, endAt, id)
  117. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  118. ctx.So(err, convey.ShouldBeNil)
  119. ctx.So(rows, convey.ShouldNotBeNil)
  120. })
  121. })
  122. })
  123. }