index_order_test.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/interface/main/space/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoindexOrderHit(t *testing.T) {
  9. convey.Convey("indexOrderHit", t, func(ctx convey.C) {
  10. var (
  11. mid = int64(708)
  12. )
  13. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  14. p1 := indexOrderHit(mid)
  15. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  16. ctx.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestDaoindexOrderKey(t *testing.T) {
  22. convey.Convey("indexOrderKey", t, func(ctx convey.C) {
  23. var (
  24. mid = int64(708)
  25. )
  26. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  27. p1 := indexOrderKey(mid)
  28. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  29. ctx.So(p1, convey.ShouldNotBeNil)
  30. })
  31. })
  32. })
  33. }
  34. func TestDaoIndexOrder(t *testing.T) {
  35. convey.Convey("IndexOrder", t, func(ctx convey.C) {
  36. var (
  37. c = context.Background()
  38. mid = int64(708)
  39. )
  40. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  41. indexOrder, err := d.IndexOrder(c, mid)
  42. ctx.Convey("Then err should be nil.indexOrder should not be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. ctx.So(indexOrder, convey.ShouldNotBeNil)
  45. })
  46. })
  47. })
  48. }
  49. func TestDaoIndexOrderModify(t *testing.T) {
  50. convey.Convey("IndexOrderModify", t, func(ctx convey.C) {
  51. var (
  52. c = context.Background()
  53. mid = int64(708)
  54. orderStr = `["1","2","8","7","3","4","5","6","21","22","23","24","25"]`
  55. )
  56. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  57. err := d.IndexOrderModify(c, mid, orderStr)
  58. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  59. ctx.So(err, convey.ShouldBeNil)
  60. })
  61. })
  62. })
  63. }
  64. func TestDaoSetIndexOrderCache(t *testing.T) {
  65. convey.Convey("SetIndexOrderCache", t, func(ctx convey.C) {
  66. var (
  67. c = context.Background()
  68. mid = int64(708)
  69. data = []*model.IndexOrder{{ID: 1, Name: "我的稿件"}}
  70. )
  71. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  72. err := d.SetIndexOrderCache(c, mid, data)
  73. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  74. ctx.So(err, convey.ShouldBeNil)
  75. })
  76. })
  77. })
  78. }
  79. func TestDaoIndexOrderCache(t *testing.T) {
  80. convey.Convey("IndexOrderCache", t, func(ctx convey.C) {
  81. var (
  82. c = context.Background()
  83. mid = int64(708)
  84. )
  85. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  86. data, err := d.IndexOrderCache(c, mid)
  87. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  88. ctx.So(err, convey.ShouldBeNil)
  89. ctx.So(data, convey.ShouldNotBeNil)
  90. })
  91. })
  92. })
  93. }
  94. func TestDaoDelIndexOrderCache(t *testing.T) {
  95. convey.Convey("DelIndexOrderCache", t, func(ctx convey.C) {
  96. var (
  97. c = context.Background()
  98. mid = int64(708)
  99. )
  100. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  101. err := d.DelIndexOrderCache(c, mid)
  102. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  103. ctx.So(err, convey.ShouldBeNil)
  104. })
  105. })
  106. })
  107. }