search_test.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/dm/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestSearchMonitor(t *testing.T) {
  9. var (
  10. c = context.TODO()
  11. aid, cid, mid, p, ps int64 = 0, 0, 0, 1, 50
  12. kw, sort, order string = "", "", ""
  13. attr = int32(0)
  14. tp = int32(1)
  15. )
  16. Convey("get monitor list from search", t, func() {
  17. res, err := testDao.SearchMonitor(c, tp, aid, cid, mid, attr, kw, sort, order, p, ps)
  18. So(err, ShouldBeNil)
  19. So(res, ShouldNotBeEmpty)
  20. t.Logf("res:%+v", res)
  21. for _, rpt := range res.Result {
  22. t.Logf("======%+v", rpt)
  23. }
  24. })
  25. }
  26. func TestSearchReports(t *testing.T) {
  27. var (
  28. c = context.TODO()
  29. tid = []int64{}
  30. rpID = []int64{1, 2}
  31. upOp = []int64{0, 1, 2}
  32. state = []int64{0, 1, 2}
  33. rt = &model.Report{
  34. Aid: -1,
  35. UID: -1,
  36. RpUID: -1,
  37. RpType: -1,
  38. Cid: -1,
  39. }
  40. )
  41. Convey("", t, func() {
  42. res, err := testDao.SearchReport(c, 1, 100, "", "", "rp_time", "desc", "", tid, rpID, state, upOp, rt)
  43. So(err, ShouldBeNil)
  44. So(res, ShouldNotBeEmpty)
  45. t.Logf("======%+v", res.Page)
  46. for _, rpt := range res.Result {
  47. t.Logf("======%+v", rpt)
  48. }
  49. })
  50. }
  51. func TestSearchReportByID(t *testing.T) {
  52. var (
  53. c = context.TODO()
  54. dmids = []int64{719218372}
  55. )
  56. Convey("", t, func() {
  57. res, err := testDao.SearchReportByID(c, dmids)
  58. So(err, ShouldBeNil)
  59. So(res, ShouldNotBeEmpty)
  60. t.Logf("===res:%v", res)
  61. for _, rpt := range res.Result {
  62. t.Logf("======%+v", rpt)
  63. }
  64. })
  65. }
  66. func TestSearchDM(t *testing.T) {
  67. var (
  68. c = context.TODO()
  69. d = &model.SearchDMParams{
  70. Type: 1,
  71. Oid: 10131232,
  72. Mid: model.CondIntNil,
  73. ProgressFrom: model.CondIntNil,
  74. ProgressTo: model.CondIntNil,
  75. CtimeFrom: model.CondIntNil,
  76. CtimeTo: model.CondIntNil,
  77. State: "",
  78. Pool: "",
  79. Attrs: "1",
  80. Page: 1,
  81. Order: "id",
  82. Sort: "asc",
  83. }
  84. )
  85. Convey("", t, func() {
  86. res, err := testDao.SearchDM(c, d)
  87. So(err, ShouldBeNil)
  88. So(res, ShouldNotBeEmpty)
  89. t.Logf("===page:%+v", res.Page)
  90. for _, rpt := range res.Result {
  91. t.Logf("======%+v", rpt)
  92. }
  93. })
  94. }
  95. func TestSendJudgement(t *testing.T) {
  96. var (
  97. c = context.TODO()
  98. li = make([]*model.ReportJudge, 0)
  99. )
  100. i := &model.ReportJudge{
  101. MID: 150781,
  102. Operator: "zhang",
  103. OperID: 121,
  104. OContent: "test dm",
  105. OTitle: "test archive",
  106. OType: 2,
  107. OURL: "https://www.bilibili.com",
  108. ReasonType: 2,
  109. AID: 11,
  110. OID: 22,
  111. RPID: 33,
  112. Page: 1,
  113. BTime: int64(1517824276),
  114. }
  115. li = append(li, i)
  116. Convey("test send judgement", t, func() {
  117. err := testDao.SendJudgement(c, li)
  118. So(err, ShouldBeNil)
  119. })
  120. }
  121. func TestUpSearchDMState(t *testing.T) {
  122. var (
  123. tp int32 = 1
  124. state int32 = 2
  125. dmids = map[int64][]int64{10131232: {1909860427366403, 1909932482887683}}
  126. )
  127. Convey("", t, func() {
  128. err := testDao.UpSearchDMState(context.TODO(), tp, state, dmids)
  129. So(err, ShouldBeNil)
  130. })
  131. }
  132. func TestUpSearchDMAttr(t *testing.T) {
  133. var (
  134. tp int32 = 1
  135. oid int64 = 10131232
  136. attr int32 = 1
  137. dmids = []int64{1909860427366403, 1909932482887683}
  138. )
  139. Convey("", t, func() {
  140. err := testDao.UpSearchDMAttr(context.TODO(), tp, oid, attr, dmids)
  141. So(err, ShouldBeNil)
  142. })
  143. }
  144. func TestUpSearchDMPool(t *testing.T) {
  145. var (
  146. tp int32 = 1
  147. oid int64 = 10131232
  148. pool int32 = 1
  149. dmids = []int64{1909860427366403, 1909932482887683}
  150. )
  151. Convey("", t, func() {
  152. err := testDao.UpSearchDMPool(context.TODO(), tp, oid, pool, dmids)
  153. So(err, ShouldBeNil)
  154. })
  155. }
  156. func TestUptSearchReport(t *testing.T) {
  157. var (
  158. uptRpt = &model.UptSearchReport{
  159. DMid: 719218991,
  160. Ctime: "2018-04-27 11:06:46",
  161. Mtime: "2018-06-07 11:06:46",
  162. State: model.StatSecondIgnore,
  163. }
  164. uptRpts = []*model.UptSearchReport{uptRpt}
  165. )
  166. Convey("test update search report", t, func() {
  167. err := testDao.UptSearchReport(context.TODO(), uptRpts)
  168. So(err, ShouldBeNil)
  169. })
  170. }
  171. func TestDaoSearchSubjectLog(t *testing.T) {
  172. Convey("SearchSubjectLog", t, func() {
  173. data, err := testDao.SearchSubjectLog(context.TODO(), 1, 1221)
  174. So(err, ShouldBeNil)
  175. So(data, ShouldNotBeNil)
  176. for _, v := range data {
  177. t.Logf("====%+v", v)
  178. }
  179. })
  180. }
  181. func TestDaoSearchSubject(t *testing.T) {
  182. r := &model.SearchSubjectReq{
  183. // Oids: []int64{10131821},
  184. Mids: []int64{0},
  185. Sort: "desc",
  186. Order: "mtime",
  187. Pn: 1,
  188. Ps: 5,
  189. State: int64(model.CondIntNil),
  190. }
  191. Convey("SearchSubject", t, func() {
  192. data, page, err := testDao.SearchSubject(context.TODO(), r)
  193. So(err, ShouldBeNil)
  194. for _, v := range data {
  195. t.Logf("====%+v", v)
  196. }
  197. t.Logf("====%+v", page)
  198. })
  199. }
  200. func TestSearchProtectCount(t *testing.T) {
  201. Convey("get protect dm count", t, func() {
  202. count, err := testDao.SearchProtectCount(context.TODO(), 1, 1221)
  203. So(err, ShouldBeNil)
  204. t.Log(count)
  205. })
  206. }
  207. func TestUpSearchRecemtDMState(t *testing.T) {
  208. var (
  209. tp int32 = 1
  210. state int32 = 2
  211. dmids = map[int64][]int64{10131232: {1909860427366403, 1909932482887683}}
  212. )
  213. Convey("", t, func() {
  214. err := testDao.UpSearchRecentDMState(context.TODO(), tp, state, dmids)
  215. So(err, ShouldBeNil)
  216. })
  217. }
  218. func TestUpSearchRecentDMAttr(t *testing.T) {
  219. var (
  220. tp int32 = 1
  221. oid int64 = 10131232
  222. attr int32 = 1
  223. dmids = []int64{1909860427366403, 1909932482887683}
  224. )
  225. Convey("", t, func() {
  226. err := testDao.UpSearchRecentDMAttr(context.TODO(), tp, oid, attr, dmids)
  227. So(err, ShouldBeNil)
  228. })
  229. }
  230. func TestUpSearchRecentDMPool(t *testing.T) {
  231. var (
  232. tp int32 = 1
  233. oid int64 = 10131232
  234. pool int32 = 1
  235. dmids = []int64{1909860427366403, 1909932482887683}
  236. )
  237. Convey("", t, func() {
  238. err := testDao.UpSearchRecentDMPool(context.TODO(), tp, oid, pool, dmids)
  239. So(err, ShouldBeNil)
  240. })
  241. }