associate_open_test.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/vip/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoOpenInfoOpenID(t *testing.T) {
  9. convey.Convey("OpenInfoOpenID", t, func(convCtx convey.C) {
  10. var (
  11. c = context.Background()
  12. openID = ""
  13. appID = int64(0)
  14. )
  15. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  16. res, err := d.RawOpenInfoByOpenID(c, openID, appID)
  17. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  18. convCtx.So(err, convey.ShouldBeNil)
  19. convCtx.So(res, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaoOpenInfoByMid(t *testing.T) {
  25. convey.Convey("OpenInfoByMid", t, func(convCtx convey.C) {
  26. var (
  27. c = context.Background()
  28. mid = int64(0)
  29. appID = int64(0)
  30. )
  31. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  32. res, err := d.OpenInfoByMid(c, mid, appID)
  33. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  34. convCtx.So(err, convey.ShouldBeNil)
  35. convCtx.So(res, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDaoByOutOpenID(t *testing.T) {
  41. convey.Convey("ByOutOpenID", t, func(convCtx convey.C) {
  42. var (
  43. c = context.Background()
  44. outOpenID = ""
  45. appID = int64(0)
  46. )
  47. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  48. res, err := d.ByOutOpenID(c, outOpenID, appID)
  49. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  50. convCtx.So(err, convey.ShouldBeNil)
  51. convCtx.So(res, convey.ShouldNotBeNil)
  52. })
  53. })
  54. })
  55. }
  56. func TestDaoRawBindInfoByMid(t *testing.T) {
  57. convey.Convey("RawBindInfoByMid", t, func(convCtx convey.C) {
  58. var (
  59. c = context.Background()
  60. mid = int64(0)
  61. appID = int64(0)
  62. )
  63. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  64. res, err := d.RawBindInfoByMid(c, mid, appID)
  65. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  66. convCtx.So(err, convey.ShouldBeNil)
  67. convCtx.So(res, convey.ShouldNotBeNil)
  68. })
  69. })
  70. })
  71. }
  72. func TestDaoTxAddBind(t *testing.T) {
  73. convey.Convey("TxAddBind", t, func(convCtx convey.C) {
  74. var (
  75. tx, _ = d.BeginTran(context.Background())
  76. arg = &model.OpenBindInfo{}
  77. )
  78. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  79. err := d.TxAddBind(tx, arg)
  80. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  81. convCtx.So(err, convey.ShouldBeNil)
  82. })
  83. tx.Commit()
  84. })
  85. })
  86. }
  87. func TestDaoTxUpdateBindByOutOpenID(t *testing.T) {
  88. convey.Convey("TxUpdateBindByOutOpenID", t, func(convCtx convey.C) {
  89. var (
  90. tx, _ = d.BeginTran(context.Background())
  91. arg = &model.OpenBindInfo{
  92. AppID: 32,
  93. OutOpenID: "test-2333",
  94. }
  95. )
  96. convCtx.Convey("When TxAddBind", func(convCtx convey.C) {
  97. err := d.TxAddBind(tx, arg)
  98. convCtx.So(err, convey.ShouldBeNil)
  99. tx.Commit()
  100. })
  101. convCtx.Convey("When TxUpdateBindByOutOpenID", func(convCtx convey.C) {
  102. err := d.TxUpdateBindByOutOpenID(tx, arg)
  103. convCtx.So(err, convey.ShouldBeNil)
  104. tx.Commit()
  105. })
  106. convCtx.Convey("When TxDeleteBindInfo", func(convCtx convey.C) {
  107. err := d.TxDeleteBindInfo(tx, arg.ID)
  108. convCtx.So(err, convey.ShouldBeNil)
  109. tx.Commit()
  110. })
  111. })
  112. }
  113. func TestDaoUpdateBindState(t *testing.T) {
  114. convey.Convey("UpdateBindState", t, func(convCtx convey.C) {
  115. var (
  116. c = context.Background()
  117. arg = &model.OpenBindInfo{}
  118. )
  119. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  120. err := d.UpdateBindState(c, arg)
  121. convCtx.So(err, convey.ShouldBeNil)
  122. })
  123. })
  124. }
  125. func TestDaoAddOpenInfo(t *testing.T) {
  126. convey.Convey("AddOpenInfo", t, func(convCtx convey.C) {
  127. var (
  128. c = context.Background()
  129. a = &model.OpenInfo{}
  130. )
  131. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  132. err := d.AddOpenInfo(c, a)
  133. convCtx.So(err, convey.ShouldBeNil)
  134. })
  135. })
  136. }
  137. func TestDaoBindInfoByOutOpenIDAndMid(t *testing.T) {
  138. convey.Convey("BindInfoByOutOpenIDAndMid", t, func(convCtx convey.C) {
  139. var (
  140. c = context.Background()
  141. mid = int64(0)
  142. outOpenID = ""
  143. appID = int64(0)
  144. )
  145. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  146. res, err := d.BindInfoByOutOpenIDAndMid(c, mid, outOpenID, appID)
  147. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  148. convCtx.So(err, convey.ShouldBeNil)
  149. convCtx.So(res, convey.ShouldNotBeNil)
  150. })
  151. })
  152. })
  153. }