refresh_test.go 2.0 KB

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