token_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package dao
  2. import (
  3. "context"
  4. "encoding/hex"
  5. "testing"
  6. "time"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoToken(t *testing.T) {
  10. var (
  11. c = context.TODO()
  12. token, _ = hex.DecodeString("baa3443180f346db244780ba6d0c6f6c")
  13. tokenNotExist, _ = hex.DecodeString("baa3443180f346db244780ba6d0c6f61")
  14. ct, _ = time.Parse("01/02/2006", "10/27/2018")
  15. )
  16. convey.Convey("Token", t, func(ctx convey.C) {
  17. res, err := d.Token(c, token, 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.Token(c, tokenNotExist, 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 TestDaoformatSuffix(t *testing.T) {
  30. var (
  31. no = time.Now()
  32. )
  33. convey.Convey("formatSuffix", t, func(ctx convey.C) {
  34. p1 := formatSuffix(no)
  35. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  36. ctx.So(p1, convey.ShouldNotBeNil)
  37. })
  38. })
  39. }