yst_test.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/tv/internal/model"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. "testing"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestDaoNewYstClient(t *testing.T) {
  11. convey.Convey("NewYstClient", t, func(ctx convey.C) {
  12. var (
  13. cli = &bm.Client{}
  14. )
  15. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  16. p1 := NewYstClient(cli)
  17. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  18. ctx.So(p1, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoNewRequest(t *testing.T) {
  24. convey.Convey("NewRequest", t, func(ctx convey.C) {
  25. var (
  26. cli = NewYstClient(&bm.Client{})
  27. uri = ""
  28. data = interface{}(0)
  29. )
  30. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  31. request, err := cli.NewRequest(uri, data)
  32. ctx.Convey("Then err should be nil.request should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. ctx.So(request, convey.ShouldNotBeNil)
  35. })
  36. })
  37. })
  38. }
  39. func TestDaoresultCode2err(t *testing.T) {
  40. convey.Convey("resultCode2err", t, func(ctx convey.C) {
  41. var (
  42. code = "999"
  43. )
  44. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  45. err := resultCode2err(code)
  46. ctx.Convey("Then err should be TVIPYstSystemErr.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldEqual, ecode.TVIPYstSystemErr)
  48. })
  49. })
  50. })
  51. }
  52. func TestDaoYstOrderState(t *testing.T) {
  53. convey.Convey("YstOrderState", t, func(ctx convey.C) {
  54. var (
  55. c = context.Background()
  56. req = &model.YstOrderStateReq{
  57. SeqNo: "08265187190109103054",
  58. TraceNo: "CA20190109102306315819491155",
  59. }
  60. )
  61. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  62. res, err := d.YstOrderState(c, req)
  63. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  64. ctx.So(err, convey.ShouldBeNil)
  65. ctx.So(res, convey.ShouldNotBeNil)
  66. })
  67. })
  68. })
  69. }