flow_test.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. package archive
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDao_TxAddFlow(t *testing.T) {
  9. var (
  10. c = context.Background()
  11. tx, _ = d.BeginTran(c)
  12. )
  13. Convey("TxAddFlow", t, func(ctx C) {
  14. _, err := d.TxAddFlow(tx, 123, 23333, 0, 0, "ut")
  15. if err != nil {
  16. tx.Rollback()
  17. } else {
  18. tx.Commit()
  19. }
  20. So(err, ShouldBeNil)
  21. })
  22. }
  23. func TestDao_TxUpFlowState(t *testing.T) {
  24. var (
  25. c = context.Background()
  26. tx, _ = d.BeginTran(c)
  27. )
  28. Convey("TxUpFlowState", t, func(ctx C) {
  29. _, err := d.TxUpFlowState(tx, 0, 23333)
  30. if err != nil {
  31. tx.Rollback()
  32. } else {
  33. tx.Commit()
  34. }
  35. So(err, ShouldBeNil)
  36. })
  37. }
  38. func TestDao_CheckFlowGroupID(t *testing.T) {
  39. var (
  40. c = context.Background()
  41. )
  42. Convey("CheckFlowGroupID", t, func(ctx C) {
  43. _, err := d.CheckFlowGroupID(c, 0, 23333, 24)
  44. So(err, ShouldBeNil)
  45. })
  46. }
  47. func TestDao_FlowPage(t *testing.T) {
  48. var (
  49. c = context.Background()
  50. )
  51. Convey("FlowPage", t, func(ctx C) {
  52. _, err := d.FlowPage(c, 0, 23333, 1, 10)
  53. So(err, ShouldBeNil)
  54. })
  55. }
  56. func TestDao_TxAddFlowLog(t *testing.T) {
  57. var (
  58. c = context.Background()
  59. tx, _ = d.BeginTran(c)
  60. )
  61. Convey("TxAddFlowLog", t, func(ctx C) {
  62. _, err := d.TxAddFlowLog(tx, 0, 123, 0, 24, "")
  63. if err != nil {
  64. tx.Rollback()
  65. } else {
  66. tx.Commit()
  67. }
  68. So(err, ShouldBeNil)
  69. })
  70. }
  71. func TestArchiveFlows(t *testing.T) {
  72. var (
  73. c = context.Background()
  74. )
  75. Convey("Flows", t, func(ctx C) {
  76. _, err := d.Flows(c)
  77. ctx.Convey("Then err should be nil.fs should not be nil.", func(ctx C) {
  78. ctx.So(err, ShouldBeNil)
  79. })
  80. })
  81. }
  82. func TestFlowsByOID(t *testing.T) {
  83. var (
  84. c = context.Background()
  85. )
  86. Convey("FlowsByOID", t, func(ctx C) {
  87. _, err := d.FlowsByOID(c, 2880441)
  88. ctx.Convey("Then err should be nil.fs should not be nil.", func(ctx C) {
  89. ctx.So(err, ShouldBeNil)
  90. })
  91. })
  92. }
  93. func TestFlowUnique(t *testing.T) {
  94. var (
  95. c = context.Background()
  96. )
  97. Convey("FlowUnique", t, func(ctx C) {
  98. _, err := d.FlowUnique(c, 2880441, 11, 0)
  99. ctx.Convey("Then err should be nil.fs should not be nil.", func(ctx C) {
  100. ctx.So(err, ShouldBeNil)
  101. })
  102. })
  103. }
  104. func TestFlowGroupPools(t *testing.T) {
  105. var (
  106. c = context.Background()
  107. )
  108. Convey("FlowGroupPools", t, func(ctx C) {
  109. _, err := d.FlowGroupPools(c, []int64{0})
  110. ctx.Convey("Then err should be nil.fs should not be nil.", func(ctx C) {
  111. ctx.So(err, ShouldBeNil)
  112. })
  113. })
  114. }
  115. func TestFlowPage(t *testing.T) {
  116. var (
  117. c = context.Background()
  118. )
  119. Convey("FlowPage", t, func(ctx C) {
  120. _, err := d.FlowPage(c, 0, 11, 1, 10)
  121. ctx.Convey("Then err should be nil.fs should not be nil.", func(ctx C) {
  122. ctx.So(err, ShouldBeNil)
  123. })
  124. })
  125. }
  126. func TestFindGroupIDByScope(t *testing.T) {
  127. var (
  128. c = context.Background()
  129. )
  130. Convey("FindGroupIDByScope", t, func(ctx C) {
  131. _, err := d.FindGroupIDByScope(c, 0, 11, 1, 1)
  132. ctx.Convey("Then err should be nil.fs should not be nil.", func(ctx C) {
  133. ctx.So(err, ShouldBeNil)
  134. })
  135. })
  136. }
  137. func TestArchiveWhiteMids(t *testing.T) {
  138. var (
  139. c = context.Background()
  140. )
  141. Convey("WhiteMids", t, func(ctx C) {
  142. _, err := d.WhiteMids(c)
  143. ctx.Convey("Then err should be nil.mids should not be nil.", func(ctx C) {
  144. ctx.So(err, ShouldBeNil)
  145. })
  146. })
  147. }
  148. func TestArchiveCheckActGroupID(t *testing.T) {
  149. var (
  150. c = context.Background()
  151. groupID = int64(1)
  152. )
  153. Convey("CheckActGroupID", t, func(ctx C) {
  154. _, err := d.CheckActGroupID(c, groupID)
  155. ctx.Convey("Then err should be nil.state should not be nil.", func(ctx C) {
  156. ctx.So(err, ShouldBeNil)
  157. })
  158. })
  159. }
  160. func TestArchiveCheckFlowMid(t *testing.T) {
  161. var (
  162. c = context.Background()
  163. pool = int8(1)
  164. oid = int64(2)
  165. )
  166. Convey("CheckFlowMid", t, func(ctx C) {
  167. _, err := d.CheckFlowMid(c, pool, oid)
  168. ctx.Convey("Then err should be nil.flows should not be nil.", func(ctx C) {
  169. ctx.So(err, ShouldBeNil)
  170. })
  171. })
  172. }
  173. func TestArchiveForbidMids(t *testing.T) {
  174. var (
  175. c = context.Background()
  176. )
  177. Convey("ForbidMids", t, func(ctx C) {
  178. _, err := d.ForbidMids(c)
  179. ctx.Convey("Then err should be nil.mids should not be nil.", func(ctx C) {
  180. ctx.So(err, ShouldBeNil)
  181. })
  182. })
  183. }
  184. func TestArchiveAppFeedAids(t *testing.T) {
  185. var (
  186. c = context.Background()
  187. startTime = time.Now()
  188. endTime = time.Now()
  189. )
  190. Convey("AppFeedAids", t, func(ctx C) {
  191. _, err := d.AppFeedAids(c, startTime, endTime)
  192. ctx.Convey("Then err should be nil.aids should not be nil.", func(ctx C) {
  193. ctx.So(err, ShouldBeNil)
  194. })
  195. })
  196. }