archive_test.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/search/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. "gopkg.in/olivere/elastic.v5"
  8. )
  9. func TestDaoArchiveCheck(t *testing.T) {
  10. convey.Convey("ArchiveCheck", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. p = &model.ArchiveCheckParams{
  14. Bsp: &model.BasicSearchParams{},
  15. Aids: []int64{0},
  16. TypeIds: []int64{0},
  17. Attrs: []int64{0},
  18. States: []int64{0},
  19. Mids: []int64{0},
  20. MidFrom: 1,
  21. MidTo: 1,
  22. DurationFrom: 1,
  23. DurationTo: 1,
  24. TimeFrom: "0001-01-01 00:00:00",
  25. TimeTo: "0001-01-01 00:00:00",
  26. Time: "ctime",
  27. }
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. _, err := d.ArchiveCheck(c, p)
  31. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. //ctx.So(res, convey.ShouldNotBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestDaoVideo(t *testing.T) {
  39. convey.Convey("Video", t, func(ctx convey.C) {
  40. var (
  41. c = context.Background()
  42. p = &model.VideoParams{
  43. Bsp: &model.BasicSearchParams{},
  44. VIDs: []int64{0},
  45. AIDs: []int64{0},
  46. CIDs: []int64{0},
  47. TIDs: []int64{0},
  48. FileNames: []string{""},
  49. RelationStates: []int64{0},
  50. ArcMids: []int64{0},
  51. TagID: 1,
  52. Status: []int64{0},
  53. XCodeState: []int64{0},
  54. UserType: 0,
  55. DurationFrom: 1,
  56. DurationTo: 1,
  57. OrderType: 1,
  58. }
  59. )
  60. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  61. _, err := d.Video(c, p)
  62. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  63. ctx.So(err, convey.ShouldBeNil)
  64. //ctx.So(res, convey.ShouldNotBeNil)
  65. })
  66. })
  67. })
  68. }
  69. func TestDaoTaskQa(t *testing.T) {
  70. convey.Convey("TaskQa", t, func(ctx convey.C) {
  71. var (
  72. c = context.Background()
  73. p = &model.TaskQa{
  74. Bsp: &model.BasicSearchParams{
  75. AppID: "task_qa",
  76. },
  77. Ids: []int64{0},
  78. TaskIds: []string{""},
  79. Uids: []string{""},
  80. ArcTagIds: []string{""},
  81. AuditTagIds: []int64{0},
  82. UpGroups: []string{""},
  83. ArcTitles: []string{""},
  84. ArcTypeIds: []string{""},
  85. States: []string{""},
  86. AuditStatuses: []string{""},
  87. FansFrom: "0",
  88. FansTo: "0",
  89. CtimeFrom: "0001-01-01 00:00:00",
  90. CtimeTo: "0001-01-01 00:00:00",
  91. FtimeFrom: "0001-01-01 00:00:00",
  92. }
  93. )
  94. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  95. res, err := d.TaskQa(c, p)
  96. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  97. ctx.So(err, convey.ShouldBeNil)
  98. ctx.So(res, convey.ShouldNotBeNil)
  99. })
  100. })
  101. })
  102. }
  103. func TestDaoArchiveCommerce(t *testing.T) {
  104. convey.Convey("ArchiveCommerce", t, func(ctx convey.C) {
  105. var (
  106. c = context.Background()
  107. p = &model.ArchiveCommerce{
  108. Bsp: &model.BasicSearchParams{},
  109. Ids: []string{"0"},
  110. Mids: []string{"0"},
  111. PTypeIds: []string{"0"},
  112. TypeIds: []string{"0"},
  113. States: []string{"0"},
  114. Copyrights: []string{"0"},
  115. OrderIds: []string{"0"},
  116. IsOrder: 1,
  117. IsOriginal: 1,
  118. Action: "get_ptypeids",
  119. }
  120. )
  121. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  122. res, err := d.ArchiveCommerce(c, p)
  123. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  124. ctx.So(err, convey.ShouldBeNil)
  125. ctx.So(res, convey.ShouldNotBeNil)
  126. })
  127. })
  128. })
  129. }
  130. func TestDaoArchiveCommercePTypeIds(t *testing.T) {
  131. convey.Convey("ArchiveCommercePTypeIds", t, func(ctx convey.C) {
  132. var (
  133. c = context.Background()
  134. query = &elastic.BoolQuery{}
  135. )
  136. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  137. res, err := d.ArchiveCommercePTypeIds(c, query)
  138. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  139. ctx.So(err, convey.ShouldBeNil)
  140. ctx.So(res, convey.ShouldNotBeNil)
  141. })
  142. })
  143. })
  144. }