mc.cache_test.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package manager
  2. import (
  3. "context"
  4. upgrpc "go-common/app/service/main/up/api/v1"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestManagerAddCacheUpSpecial(t *testing.T) {
  9. convey.Convey("AddCacheUpSpecial", t, func(convCtx convey.C) {
  10. var (
  11. c = context.Background()
  12. id = int64(0)
  13. val = &upgrpc.UpSpecial{}
  14. )
  15. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  16. err := d.AddCacheUpSpecial(c, id, val)
  17. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  18. convCtx.So(err, convey.ShouldBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestManagerCacheUpSpecial(t *testing.T) {
  24. convey.Convey("CacheUpSpecial", t, func(convCtx convey.C) {
  25. var (
  26. c = context.Background()
  27. id = int64(0)
  28. )
  29. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  30. res, err := d.CacheUpSpecial(c, id)
  31. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  32. convCtx.So(err, convey.ShouldBeNil)
  33. convCtx.So(res, convey.ShouldNotBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestManagerDelCacheUpSpecial(t *testing.T) {
  39. convey.Convey("DelCacheUpSpecial", t, func(convCtx convey.C) {
  40. var (
  41. c = context.Background()
  42. id = int64(0)
  43. )
  44. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  45. err := d.DelCacheUpSpecial(c, id)
  46. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  47. convCtx.So(err, convey.ShouldBeNil)
  48. })
  49. })
  50. })
  51. }
  52. func TestManagerAddCacheUpsSpecial(t *testing.T) {
  53. convey.Convey("AddCacheUpsSpecial", t, func(convCtx convey.C) {
  54. var (
  55. c = context.Background()
  56. values map[int64]*upgrpc.UpSpecial
  57. )
  58. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  59. err := d.AddCacheUpsSpecial(c, values)
  60. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  61. convCtx.So(err, convey.ShouldBeNil)
  62. })
  63. })
  64. })
  65. }
  66. func TestManagerCacheUpsSpecial(t *testing.T) {
  67. convey.Convey("CacheUpsSpecial", t, func(convCtx convey.C) {
  68. var (
  69. c = context.Background()
  70. ids = []int64{27515256}
  71. )
  72. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  73. res, err := d.CacheUpsSpecial(c, ids)
  74. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  75. convCtx.So(err, convey.ShouldBeNil)
  76. convCtx.So(res, convey.ShouldNotBeNil)
  77. })
  78. })
  79. })
  80. }
  81. func TestManagerDelCacheUpsSpecial(t *testing.T) {
  82. convey.Convey("DelCacheUpsSpecial", t, func(convCtx convey.C) {
  83. var (
  84. c = context.Background()
  85. ids = []int64{}
  86. )
  87. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  88. err := d.DelCacheUpsSpecial(c, ids)
  89. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  90. convCtx.So(err, convey.ShouldBeNil)
  91. })
  92. })
  93. })
  94. }