dao.cache_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "time"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoInfos(t *testing.T) {
  10. convey.Convey("Infos", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. keys = _testMids
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. for _, v := range keys {
  17. err := d.DelInfoCache(c, v)
  18. ctx.So(err, convey.ShouldBeNil)
  19. }
  20. res, err := d.Infos(c, keys)
  21. fmt.Println("res", res)
  22. time.Sleep(100 * time.Millisecond)
  23. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  24. ctx.So(err, convey.ShouldBeNil)
  25. ctx.So(res, convey.ShouldNotBeNil)
  26. })
  27. _, err = d.Infos(c, keys)
  28. ctx.So(err, convey.ShouldBeNil)
  29. })
  30. })
  31. }
  32. func TestDaoInfo(t *testing.T) {
  33. convey.Convey("Info", t, func(ctx convey.C) {
  34. var (
  35. c = context.Background()
  36. id = _testMid
  37. )
  38. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  39. err := d.DelInfoCache(c, _testMid)
  40. ctx.So(err, convey.ShouldBeNil)
  41. res, err := d.Info(c, id)
  42. time.Sleep(100 * time.Millisecond)
  43. fmt.Println("res", res.VipType, res.VipStatus)
  44. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  45. ctx.So(err, convey.ShouldBeNil)
  46. ctx.So(res, convey.ShouldNotBeNil)
  47. })
  48. res, err = d.Info(c, id)
  49. ctx.So(err, convey.ShouldBeNil)
  50. })
  51. })
  52. }