privacy_test.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/space/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoprivacyHit(t *testing.T) {
  9. convey.Convey("privacyHit", t, func(ctx convey.C) {
  10. var (
  11. mid = int64(2222)
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. p1 := privacyHit(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 TestDaoprivacyKey(t *testing.T) {
  22. convey.Convey("privacyKey", t, func(ctx convey.C) {
  23. var (
  24. mid = int64(2222)
  25. )
  26. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  27. p1 := privacyKey(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 TestDaoPrivacy(t *testing.T) {
  35. convey.Convey("Privacy", t, func(ctx convey.C) {
  36. var (
  37. c = context.Background()
  38. mid = int64(2222)
  39. )
  40. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  41. data, err := d.Privacy(c, mid)
  42. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. ctx.So(data, convey.ShouldNotBeNil)
  45. })
  46. })
  47. })
  48. }
  49. func TestDaoPrivacyModify(t *testing.T) {
  50. convey.Convey("PrivacyModify", t, func(ctx convey.C) {
  51. var (
  52. c = context.Background()
  53. mid = int64(2222)
  54. field = "bangumi"
  55. value = int(0)
  56. )
  57. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  58. err := d.PrivacyModify(c, mid, field, value)
  59. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  60. ctx.So(err, convey.ShouldBeNil)
  61. })
  62. })
  63. })
  64. }
  65. func TestDaoSetPrivacyCache(t *testing.T) {
  66. convey.Convey("SetPrivacyCache", t, func(ctx convey.C) {
  67. var (
  68. c = context.Background()
  69. mid = int64(2222)
  70. data = model.DefaultPrivacy
  71. )
  72. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  73. err := d.SetPrivacyCache(c, mid, data)
  74. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  75. ctx.So(err, convey.ShouldBeNil)
  76. })
  77. })
  78. })
  79. }
  80. func TestDaoPrivacyCache(t *testing.T) {
  81. convey.Convey("PrivacyCache", t, func(ctx convey.C) {
  82. var (
  83. c = context.Background()
  84. mid = int64(2222)
  85. )
  86. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  87. data, err := d.PrivacyCache(c, mid)
  88. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  89. ctx.So(err, convey.ShouldBeNil)
  90. ctx.So(data, convey.ShouldNotBeNil)
  91. })
  92. })
  93. })
  94. }
  95. func TestDaoDelPrivacyCache(t *testing.T) {
  96. convey.Convey("DelPrivacyCache", t, func(ctx convey.C) {
  97. var (
  98. c = context.Background()
  99. mid = int64(2222)
  100. )
  101. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  102. err := d.DelPrivacyCache(c, mid)
  103. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  104. ctx.So(err, convey.ShouldBeNil)
  105. })
  106. })
  107. })
  108. }