passport_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoAccessToken(t *testing.T) {
  8. var (
  9. c = context.Background()
  10. accesskey = "accessKey"
  11. target = "origin"
  12. )
  13. convey.Convey("AccessToken", t, func(ctx convey.C) {
  14. token, err := d.AccessToken(c, accesskey, target)
  15. ctx.Convey("Then err should be nil.token should not be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldEqual, -101)
  17. ctx.So(token, convey.ShouldBeNil)
  18. })
  19. })
  20. }
  21. func TestDaoRenewToken(t *testing.T) {
  22. var (
  23. c = context.Background()
  24. accesskey = "accessKey"
  25. target = "origin"
  26. )
  27. convey.Convey("RenewToken", t, func(ctx convey.C) {
  28. renewToken, err := d.RenewToken(c, accesskey, target)
  29. ctx.Convey("Then err should be nil.renewToken should not be nil.", func(ctx convey.C) {
  30. ctx.So(err, convey.ShouldEqual, -101)
  31. ctx.So(renewToken, convey.ShouldBeNil)
  32. })
  33. })
  34. }
  35. func TestGetCookieByMid(t *testing.T) {
  36. var (
  37. c = context.Background()
  38. mid = int64(234112334566723432)
  39. )
  40. convey.Convey("GetCookieByMid", t, func(ctx convey.C) {
  41. cookies, err := d.GetCookieByMid(c, mid)
  42. convey.So(err, convey.ShouldNotBeNil)
  43. convey.So(cookies, convey.ShouldBeNil)
  44. })
  45. }