http_test.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/library/ecode"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoPayRefund(t *testing.T) {
  9. convey.Convey("PayRefund", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. dataJSON = ""
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. err := d.PayRefund(c, dataJSON)
  16. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldEqual, ecode.Int(8004020001))
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoPayCancel(t *testing.T) {
  23. convey.Convey("PayCancel", t, func(ctx convey.C) {
  24. var (
  25. c = context.Background()
  26. dataJSON = ""
  27. )
  28. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  29. err := d.PayCancel(c, dataJSON)
  30. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  31. ctx.So(err, convey.ShouldEqual, ecode.Int(8004020001))
  32. })
  33. })
  34. })
  35. }
  36. func TestDaoPayQuery(t *testing.T) {
  37. convey.Convey("PayQuery", t, func(ctx convey.C) {
  38. var (
  39. c = context.Background()
  40. dataJSON = `{"customerId":"10017","orderIds":"77546846181122123422","sign":"860d970710eac87650f221d0e0db6940","signType":"MD5","timestamp":"1542882768000","traceId":"1542882768117855000","version":"1.0"}`
  41. )
  42. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  43. _, err := d.PayQuery(c, dataJSON)
  44. ctx.Convey("Then err should be nil.orders should not be nil.", func(ctx convey.C) {
  45. ctx.So(err, convey.ShouldBeNil)
  46. })
  47. })
  48. })
  49. }