mc.cache_test.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoCacheUserCoin(t *testing.T) {
  8. var (
  9. c = context.TODO()
  10. id = int64(1)
  11. )
  12. convey.Convey("CacheUserCoin", t, func(ctx convey.C) {
  13. res, err := d.CacheUserCoin(c, id)
  14. ctx.Convey("Error should be nil", func(ctx convey.C) {
  15. ctx.So(err, convey.ShouldBeNil)
  16. })
  17. ctx.Convey("res should not be nil", func(ctx convey.C) {
  18. ctx.So(res, convey.ShouldNotBeNil)
  19. })
  20. })
  21. }
  22. func TestDaoAddCacheUserCoin(t *testing.T) {
  23. var (
  24. c = context.TODO()
  25. id = int64(10)
  26. val = float64(10)
  27. )
  28. convey.Convey("AddCacheUserCoin", t, func(ctx convey.C) {
  29. err := d.AddCacheUserCoin(c, id, val)
  30. ctx.Convey("Error should be nil", func(ctx convey.C) {
  31. ctx.So(err, convey.ShouldBeNil)
  32. })
  33. })
  34. }
  35. func TestDaoCacheItemCoin(t *testing.T) {
  36. var (
  37. c = context.TODO()
  38. id = int64(1)
  39. tp = int64(60)
  40. )
  41. convey.Convey("CacheItemCoin", t, func(ctx convey.C) {
  42. res, err := d.CacheItemCoin(c, id, tp)
  43. ctx.Convey("Error should be nil", func(ctx convey.C) {
  44. ctx.So(err, convey.ShouldBeNil)
  45. })
  46. ctx.Convey("res should not be nil", func(ctx convey.C) {
  47. ctx.So(res, convey.ShouldNotBeNil)
  48. })
  49. })
  50. }
  51. func TestDaoAddCacheItemCoin(t *testing.T) {
  52. var (
  53. c = context.TODO()
  54. id = int64(1)
  55. val = int64(10)
  56. tp = int64(60)
  57. )
  58. convey.Convey("AddCacheItemCoin", t, func(ctx convey.C) {
  59. err := d.AddCacheItemCoin(c, id, val, tp)
  60. ctx.Convey("Error should be nil", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. })
  63. })
  64. }
  65. func TestDaoExp(t *testing.T) {
  66. var (
  67. c = context.TODO()
  68. id = int64(1)
  69. )
  70. convey.Convey("Exp", t, func(ctx convey.C) {
  71. res, err := d.Exp(c, id)
  72. ctx.Convey("Error should be nil", func(ctx convey.C) {
  73. ctx.So(err, convey.ShouldBeNil)
  74. })
  75. ctx.Convey("res should not be nil", func(ctx convey.C) {
  76. ctx.So(res, convey.ShouldNotBeNil)
  77. })
  78. })
  79. }
  80. func TestDaoSetTodayExpCache(t *testing.T) {
  81. var (
  82. c = context.TODO()
  83. id = int64(1)
  84. val = int64(10)
  85. )
  86. convey.Convey("SetTodayExpCache", t, func(ctx convey.C) {
  87. err := d.SetTodayExpCache(c, id, val)
  88. ctx.Convey("Error should be nil", func(ctx convey.C) {
  89. ctx.So(err, convey.ShouldBeNil)
  90. })
  91. })
  92. }