redis_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/history/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaokeyIndex(t *testing.T) {
  9. convey.Convey("keyIndex", t, func(ctx convey.C) {
  10. var (
  11. business = ""
  12. mid = int64(14771787)
  13. )
  14. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  15. p1 := keyIndex(business, mid)
  16. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  17. ctx.So(p1, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaokeyHistory(t *testing.T) {
  23. convey.Convey("keyHistory", t, func(ctx convey.C) {
  24. var (
  25. business = "archive"
  26. mid = int64(14771787)
  27. )
  28. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  29. p1 := keyHistory(business, mid)
  30. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  31. ctx.So(p1, convey.ShouldNotBeNil)
  32. })
  33. })
  34. })
  35. }
  36. func TestDaoHistoriesCache(t *testing.T) {
  37. convey.Convey("HistoriesCache", t, func(ctx convey.C) {
  38. var (
  39. c = context.Background()
  40. merges = []*model.Merge{}
  41. )
  42. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  43. _, err := d.HistoriesCache(c, merges)
  44. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  45. ctx.So(err, convey.ShouldBeNil)
  46. })
  47. })
  48. })
  49. }
  50. func TestDaoTrimCache(t *testing.T) {
  51. convey.Convey("TrimCache", t, func(ctx convey.C) {
  52. var (
  53. c = context.Background()
  54. business = ""
  55. mid = int64(14771787)
  56. limit = int(10)
  57. )
  58. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  59. err := d.TrimCache(c, business, mid, limit)
  60. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. })
  63. })
  64. })
  65. }
  66. func TestDaoDelCache(t *testing.T) {
  67. convey.Convey("DelCache", t, func(ctx convey.C) {
  68. var (
  69. c = context.Background()
  70. business = ""
  71. mid = int64(14771787)
  72. aids = []int64{}
  73. )
  74. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  75. err := d.DelCache(c, business, mid, aids)
  76. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  77. if err != nil {
  78. ctx.So(err, convey.ShouldNotBeNil)
  79. } else {
  80. ctx.So(err, convey.ShouldBeNil)
  81. }
  82. })
  83. })
  84. })
  85. }
  86. func TestDaoDelLock(t *testing.T) {
  87. convey.Convey("DelLock", t, func(ctx convey.C) {
  88. var (
  89. c = context.Background()
  90. )
  91. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  92. ok, err := d.DelLock(c)
  93. ctx.Convey("Then err should be nil.ok should not be nil.", func(ctx convey.C) {
  94. ctx.So(err, convey.ShouldBeNil)
  95. ctx.So(ok, convey.ShouldNotBeNil)
  96. })
  97. })
  98. })
  99. }