redis_test.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoAddCacheAssetRelationState(t *testing.T) {
  8. convey.Convey("AddCacheAssetRelationState", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. oid = int64(2233)
  12. otype = "archive"
  13. mid = int64(46333)
  14. state = "paid"
  15. )
  16. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  17. err := d.AddCacheAssetRelationState(c, oid, otype, mid, state)
  18. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaoassetRelationKey(t *testing.T) {
  25. convey.Convey("assetRelationKey", t, func(ctx convey.C) {
  26. var (
  27. mid = int64(46333)
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. p1 := assetRelationKey(mid)
  31. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  32. ctx.So(p1, convey.ShouldNotBeNil)
  33. })
  34. })
  35. })
  36. }
  37. func TestDaoassetRelationField(t *testing.T) {
  38. convey.Convey("assetRelationField", t, func(ctx convey.C) {
  39. var (
  40. oid = int64(2233)
  41. otype = "archive"
  42. )
  43. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  44. p1 := assetRelationField(oid, otype)
  45. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  46. ctx.So(p1, convey.ShouldNotBeNil)
  47. })
  48. })
  49. })
  50. }
  51. func TestDaopingRedis(t *testing.T) {
  52. convey.Convey("pingRedis", t, func(ctx convey.C) {
  53. var (
  54. c = context.Background()
  55. )
  56. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  57. err := d.pingRedis(c)
  58. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  59. ctx.So(err, convey.ShouldBeNil)
  60. })
  61. })
  62. })
  63. }
  64. func TestDaoCacheAssetRelationState(t *testing.T) {
  65. convey.Convey("CacheAssetRelationState", t, func(ctx convey.C) {
  66. var (
  67. c = context.Background()
  68. oid = int64(2233)
  69. otype = "archive"
  70. mid = int64(46333)
  71. )
  72. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  73. state, err := d.CacheAssetRelationState(c, oid, otype, mid)
  74. ctx.Convey("Then err should be nil.state should not be nil.", func(ctx convey.C) {
  75. ctx.So(err, convey.ShouldBeNil)
  76. ctx.So(state, convey.ShouldEqual, "paid")
  77. })
  78. })
  79. })
  80. }
  81. func TestDaoDelCacheAssetRelationState(t *testing.T) {
  82. convey.Convey("DelCacheAssetRelationState", t, func(ctx convey.C) {
  83. var (
  84. c = context.Background()
  85. oid = int64(2233)
  86. otype = "archive"
  87. mid = int64(46333)
  88. )
  89. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  90. err := d.DelCacheAssetRelationState(c, oid, otype, mid)
  91. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  92. ctx.So(err, convey.ShouldBeNil)
  93. })
  94. })
  95. })
  96. }
  97. func TestDaoDelCacheAssetRelation(t *testing.T) {
  98. convey.Convey("DelCacheAssetRelation", t, func(ctx convey.C) {
  99. var (
  100. c = context.Background()
  101. mid = int64(46333)
  102. )
  103. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  104. err := d.DelCacheAssetRelation(c, mid)
  105. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  106. ctx.So(err, convey.ShouldBeNil)
  107. })
  108. })
  109. })
  110. }