token_test.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/job/main/passport-auth/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoAddToken(t *testing.T) {
  10. convey.Convey("AddToken", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. no = &model.Token{}
  14. token = []byte("9df38fe4b94a47baad001ad823b84110")
  15. ct = time.Now()
  16. )
  17. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  18. affected, err := d.AddToken(c, no, token, ct)
  19. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  20. ctx.So(err, convey.ShouldBeNil)
  21. ctx.So(affected, convey.ShouldNotBeNil)
  22. })
  23. })
  24. })
  25. }
  26. func TestDaoDelToken(t *testing.T) {
  27. convey.Convey("DelToken", t, func(ctx convey.C) {
  28. var (
  29. c = context.Background()
  30. token = []byte("9df38fe4b94a47baad001ad823b84110")
  31. ct = time.Now()
  32. )
  33. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  34. affected, err := d.DelToken(c, token, ct)
  35. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  36. ctx.So(err, convey.ShouldBeNil)
  37. ctx.So(affected, convey.ShouldNotBeNil)
  38. })
  39. })
  40. })
  41. }
  42. func TestDaoAddTokenDeleted(t *testing.T) {
  43. convey.Convey("AddTokenDeleted", t, func(ctx convey.C) {
  44. var (
  45. c = context.Background()
  46. no = &model.Token{}
  47. token = []byte("9df38fe4b94a47baad001ad823b84110")
  48. ct = time.Now()
  49. )
  50. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  51. affected, err := d.AddTokenDeleted(c, no, token, ct)
  52. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  53. ctx.So(err, convey.ShouldBeNil)
  54. ctx.So(affected, convey.ShouldNotBeNil)
  55. })
  56. })
  57. })
  58. }
  59. func TestDaoformatSuffix(t *testing.T) {
  60. convey.Convey("formatSuffix", t, func(ctx convey.C) {
  61. var (
  62. no = time.Now()
  63. )
  64. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  65. p1 := formatSuffix(no)
  66. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  67. ctx.So(p1, convey.ShouldNotBeNil)
  68. })
  69. })
  70. })
  71. }