refresh_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package dao
  2. import (
  3. "context"
  4. "encoding/hex"
  5. "testing"
  6. "time"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoRefresh(t *testing.T) {
  10. var (
  11. c = context.TODO()
  12. rk, _ = hex.DecodeString("5f1813d287eb4238f2eadf225bda5d84")
  13. rkNotExist, _ = hex.DecodeString("5f1813d287eb4238f2eadf225bda5d81")
  14. ct, _ = time.Parse("01/02/2006", "08/27/2018")
  15. )
  16. convey.Convey("Refresh", t, func(ctx convey.C) {
  17. res, err := d.Refresh(c, rk, ct)
  18. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldBeNil)
  20. ctx.So(res, convey.ShouldNotBeNil)
  21. })
  22. res2, err2 := d.Refresh(c, rkNotExist, ct)
  23. ctx.Convey("Then err should be nil.res should be nil.", func(ctx convey.C) {
  24. ctx.So(err2, convey.ShouldBeNil)
  25. ctx.So(res2, convey.ShouldBeNil)
  26. })
  27. })
  28. }
  29. func TestDaoformatRefreshSuffix(t *testing.T) {
  30. var (
  31. no = time.Now()
  32. )
  33. convey.Convey("formatRefreshSuffix", t, func(ctx convey.C) {
  34. p1 := formatRefreshSuffix(no)
  35. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  36. ctx.So(p1, convey.ShouldNotBeNil)
  37. })
  38. })
  39. }
  40. func TestDaoformatByDate(t *testing.T) {
  41. var (
  42. year = int(2018)
  43. month = int(8)
  44. )
  45. convey.Convey("formatByDate", t, func(ctx convey.C) {
  46. p1 := formatByDate(year, month)
  47. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  48. ctx.So(p1, convey.ShouldNotBeNil)
  49. })
  50. })
  51. }