search_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/dm2/model"
  6. "time"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestSearchDM(t *testing.T) {
  10. p := &model.SearchDMParams{
  11. Oid: 10131156,
  12. Mids: "",
  13. Keyword: "",
  14. ProgressFrom: model.CondIntNil,
  15. ProgressTo: model.CondIntNil,
  16. CtimeFrom: "",
  17. CtimeTo: "",
  18. Pn: 1,
  19. Ps: 100,
  20. State: "0",
  21. Type: 1,
  22. Mode: "",
  23. Sort: "desc",
  24. Order: "ctime",
  25. Pool: "",
  26. Attrs: "",
  27. }
  28. Convey("", t, func() {
  29. res, err := testDao.SearchDM(context.TODO(), p)
  30. So(err, ShouldBeNil)
  31. So(res, ShouldNotBeEmpty)
  32. t.Logf("%+v", res.Page)
  33. for i, v := range res.Result {
  34. t.Logf("%d %v", i, v)
  35. }
  36. })
  37. }
  38. func TestSearchDMHisIndex(t *testing.T) {
  39. Convey("search dm history index", t, func() {
  40. dates, err := testDao.SearchDMHisIndex(context.TODO(), 1, 10109227, "2018-03")
  41. So(err, ShouldBeNil)
  42. So(dates, ShouldNotBeEmpty)
  43. t.Log(dates)
  44. })
  45. }
  46. func TestSearchDMHistory(t *testing.T) {
  47. Convey("search dm history", t, func() {
  48. ctime, err := time.Parse("2006-01-02 15:04:05", "2016-08-03 23:59:59")
  49. if err != nil {
  50. t.Fail()
  51. }
  52. dmids, err := testDao.SearchDMHistory(context.TODO(), 1, 1221, ctime.Unix(), 1, 100)
  53. So(err, ShouldBeNil)
  54. So(dmids, ShouldNotBeEmpty)
  55. t.Log(dmids)
  56. })
  57. }
  58. func TestUptSearchDMPool(t *testing.T) {
  59. Convey("update search dm pool", t, func() {
  60. err := testDao.UptSearchDMPool(context.TODO(), []int64{416894555258883, 372530664701955}, 10131156, 1, 1)
  61. So(err, ShouldBeNil)
  62. })
  63. }
  64. func TestUptSearchDMState(t *testing.T) {
  65. Convey("update search dm state", t, func() {
  66. err := testDao.UptSearchDMState(context.TODO(), []int64{372412118466563}, 10131156, 1, 1)
  67. So(err, ShouldBeNil)
  68. })
  69. }
  70. func TestUptSearchDMAttr(t *testing.T) {
  71. Convey("update search dm attr", t, func() {
  72. err := testDao.UptSearchDMAttr(context.TODO(), []int64{372412118466563}, 10131156, 0, 1)
  73. So(err, ShouldBeNil)
  74. })
  75. }
  76. func TestSearchSubtitles(t *testing.T) {
  77. Convey("search subtitle", t, func() {
  78. res, err := testDao.SearchSubtitles(context.TODO(), 1, 10, 0, nil, 0, 0, 0, nil)
  79. So(err, ShouldBeNil)
  80. t.Logf("page:%+v", res.Page)
  81. t.Logf("results:%v", len(res.Results))
  82. for _, rs := range res.Results {
  83. t.Logf("rs:%+v", rs)
  84. }
  85. })
  86. }
  87. func TestCountSubtitles(t *testing.T) {
  88. Convey("search subtitle", t, func() {
  89. res, err := testDao.CountSubtitles(context.TODO(), 0, nil, 0, 0, 0)
  90. So(err, ShouldBeNil)
  91. t.Logf("page:%+v", res)
  92. })
  93. }