sign_test.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package mcndao
  2. import (
  3. "testing"
  4. "go-common/app/interface/main/mcn/model"
  5. "go-common/app/interface/main/mcn/model/mcnmodel"
  6. "go-common/library/ecode"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestMcndaoGetMcnSignState(t *testing.T) {
  10. convey.Convey("GetMcnSignState", t, func(ctx convey.C) {
  11. var (
  12. fields = "*"
  13. mcnMid = int64(0)
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. mcn, state, err := d.GetMcnSignState(fields, mcnMid)
  17. ctx.Convey("Then err should be nil.mcn,state should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldEqual, -404)
  19. ctx.So(state, convey.ShouldNotBeNil)
  20. ctx.So(mcn, convey.ShouldBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestMcndaoGetUpBind(t *testing.T) {
  26. convey.Convey("GetUpBind", t, func(ctx convey.C) {
  27. var (
  28. query = "1=?"
  29. args = "0"
  30. )
  31. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  32. upList, err := d.GetUpBind(query, args)
  33. ctx.Convey("Then err should be nil.upList should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(upList, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestMcndaoBindUp(t *testing.T) {
  41. convey.Convey("BindUp", t, func(ctx convey.C) {
  42. var (
  43. up = &mcnmodel.McnUp{}
  44. sign = &mcnmodel.McnSign{}
  45. arg = &mcnmodel.McnBindUpApplyReq{}
  46. )
  47. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  48. result, affectedRow, err := d.BindUp(up, sign, arg)
  49. ctx.Convey("Then err should be nil.result,affectedRow should not be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldEqual, 82010)
  51. ctx.So(affectedRow, convey.ShouldEqual, 0)
  52. ctx.So(result, convey.ShouldBeNil)
  53. })
  54. })
  55. })
  56. }
  57. func TestMcndaoUpdateBindUp(t *testing.T) {
  58. convey.Convey("UpdateBindUp", t, func(ctx convey.C) {
  59. var (
  60. values map[string]interface{}
  61. query = interface{}(0)
  62. args = interface{}(0)
  63. )
  64. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  65. affectedRow, err := d.UpdateBindUp(values, query, args)
  66. ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
  67. ctx.So(err, convey.ShouldBeNil)
  68. ctx.So(affectedRow, convey.ShouldNotBeNil)
  69. })
  70. })
  71. })
  72. }
  73. func TestMcndaoUpConfirm(t *testing.T) {
  74. convey.Convey("UpConfirm", t, func(ctx convey.C) {
  75. var (
  76. arg = &mcnmodel.McnUpConfirmReq{}
  77. state model.MCNUPState
  78. )
  79. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  80. err := d.UpConfirm(arg, state)
  81. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  82. ctx.So(err, convey.ShouldBeNil)
  83. })
  84. })
  85. })
  86. }
  87. func TestMcndaoGetBindInfo(t *testing.T) {
  88. convey.Convey("GetBindInfo", t, func(ctx convey.C) {
  89. var (
  90. arg = &mcnmodel.McnUpGetBindReq{}
  91. )
  92. arg.BindID = 10
  93. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  94. res, err := d.GetBindInfo(arg)
  95. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  96. if err == ecode.NothingFound {
  97. ctx.So(err, convey.ShouldNotBeNil)
  98. } else {
  99. ctx.So(err, convey.ShouldBeNil)
  100. }
  101. if res != nil {
  102. ctx.So(res, convey.ShouldNotBeNil)
  103. } else {
  104. ctx.So(res, convey.ShouldBeNil)
  105. }
  106. })
  107. })
  108. })
  109. }
  110. func TestMcndaoGetMcnOldInfo(t *testing.T) {
  111. convey.Convey("GetMcnOldInfo", t, func(ctx convey.C) {
  112. var (
  113. mcnMid = int64(0)
  114. )
  115. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  116. res, err := d.GetMcnOldInfo(mcnMid)
  117. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  118. ctx.So(err, convey.ShouldEqual, -404)
  119. ctx.So(res, convey.ShouldNotBeNil)
  120. })
  121. })
  122. })
  123. }