cookie_test.go 904 B

1234567891011121314151617181920212223242526272829303132
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoCookie(t *testing.T) {
  9. var (
  10. c = context.TODO()
  11. sd = []byte("5ebd8ebb,1530838806,2c8d0678")
  12. sdNotExist = []byte("9f1c9145,1536117849,c9fb62a2")
  13. ct, _ = time.Parse("01/02/2006", "07/27/2018")
  14. )
  15. convey.Convey("Cookie", t, func(ctx convey.C) {
  16. res, session, err := d.Cookie(c, sd, ct)
  17. ctx.Convey("Then err should be nil.res,session should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(session, convey.ShouldNotBeNil)
  20. ctx.So(res, convey.ShouldNotBeNil)
  21. })
  22. res2, session2, err2 := d.Cookie(c, sdNotExist, ct)
  23. ctx.Convey("Then err should be nil.res,session should be nil.", func(ctx convey.C) {
  24. ctx.So(err2, convey.ShouldBeNil)
  25. ctx.So(session2, convey.ShouldBeNil)
  26. ctx.So(res2, convey.ShouldBeNil)
  27. })
  28. })
  29. }