http_test.go 709 B

1234567891011121314151617181920212223242526272829
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. "gopkg.in/h2non/gock.v1"
  7. )
  8. func TestDao_UpdateAccFace(t *testing.T) {
  9. Convey("UpdateAccFace", t, func() {
  10. Convey("When everything goes positive", func() {
  11. defer gock.OffAll()
  12. httpMock("POST", _updateFaceURL).Reply(200).JSON(`{"code":0}`)
  13. err := d.UpdateAccFace(context.TODO(), 1, "1456")
  14. So(err, ShouldBeNil)
  15. })
  16. Convey("When everything goes negative", func() {
  17. defer gock.OffAll()
  18. httpMock("POST", _updateFaceURL).Reply(200).JSON(`{"code":500}`)
  19. err := d.UpdateAccFace(context.TODO(), 1, "1456")
  20. Convey("Then err should be nil.", func() {
  21. So(err, ShouldNotBeNil)
  22. })
  23. })
  24. })
  25. }