up_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package account
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. gock "gopkg.in/h2non/gock.v1"
  7. )
  8. const (
  9. mid = int64(2089809)
  10. ip = "127.0.0.1"
  11. )
  12. func TestPhoneEmail(t *testing.T) {
  13. var (
  14. c = context.TODO()
  15. ck = "iamck"
  16. )
  17. convey.Convey("PhoneEmail", t, func(ctx convey.C) {
  18. defer gock.OffAll()
  19. httpMock("GET", d.passURI).Reply(200).JSON(`{"code":20007}`)
  20. ret, err := d.PhoneEmail(c, ck, ip)
  21. ctx.Convey("Then err should be nil.ret should not be nil.", func(ctx convey.C) {
  22. ctx.So(err, convey.ShouldNotBeNil)
  23. ctx.So(ret, convey.ShouldBeNil)
  24. })
  25. })
  26. }
  27. func TestAccountPic(t *testing.T) {
  28. var (
  29. c = context.TODO()
  30. )
  31. convey.Convey("Pic", t, func(ctx convey.C) {
  32. defer gock.OffAll()
  33. httpMock("GET", d.picUpInfoURL).Reply(200).JSON(`{"code":0,"data":{"has_doc":100}}`)
  34. has, err := d.Pic(c, mid, ip)
  35. ctx.Convey("Then err should be nil.has should not be nil.", func(ctx convey.C) {
  36. ctx.So(err, convey.ShouldBeNil)
  37. ctx.So(has, convey.ShouldNotBeNil)
  38. })
  39. })
  40. }
  41. func TestAccountBlink(t *testing.T) {
  42. var (
  43. c = context.TODO()
  44. )
  45. convey.Convey("Blink", t, func(ctx convey.C) {
  46. defer gock.OffAll()
  47. httpMock("GET", d.blinkUpInfoURL).Reply(200).JSON(`{"code":0,"data":{"has":100}}`)
  48. has, err := d.Blink(c, mid, ip)
  49. ctx.Convey("Then err should be nil.has should not be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. ctx.So(has, convey.ShouldNotBeNil)
  52. })
  53. })
  54. }