account_redis_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/web/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaokeyCard(t *testing.T) {
  9. convey.Convey("keyCard", 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 := keyCard(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 TestDaoSetCardBakCache(t *testing.T) {
  22. convey.Convey("SetCardBakCache", t, func(ctx convey.C) {
  23. var (
  24. c = context.Background()
  25. mid = int64(2222)
  26. rs = &model.Card{Card: &model.AccountCard{Mid: "2222"}, Space: &model.Space{}}
  27. )
  28. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  29. err := d.SetCardBakCache(c, mid, rs)
  30. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  31. ctx.So(err, convey.ShouldBeNil)
  32. })
  33. })
  34. })
  35. }
  36. func TestDaoCardBakCache(t *testing.T) {
  37. convey.Convey("CardBakCache", t, func(ctx convey.C) {
  38. var (
  39. c = context.Background()
  40. mid = int64(2222)
  41. )
  42. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  43. rs, err := d.CardBakCache(c, mid)
  44. ctx.Convey("Then err should be nil.rs should not be nil.", func(ctx convey.C) {
  45. ctx.So(err, convey.ShouldBeNil)
  46. ctx.Printf("%+v", rs)
  47. })
  48. })
  49. })
  50. }
  51. func TestDaocommonSetBakCache(t *testing.T) {
  52. convey.Convey("commonSetBakCache", t, func(ctx convey.C) {
  53. var (
  54. c = context.Background()
  55. key = ""
  56. bs = []byte("")
  57. )
  58. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  59. err := d.commonSetBakCache(c, key, bs)
  60. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. })
  63. })
  64. })
  65. }