http_search_test.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "time"
  7. "go-common/app/admin/main/reply/model"
  8. xtime "go-common/library/time"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. func TestUpdateReply(t *testing.T) {
  12. Convey("update search reply", t, WithDao(func(d *Dao) {
  13. err := d.UpSearchReply(context.Background(), map[int64]*model.Reply{111852176: &model.Reply{
  14. ID: 111852176,
  15. Oid: 10098544,
  16. Type: 1,
  17. CTime: xtime.Time(1534412702),
  18. MTime: xtime.Time(time.Now().Unix()),
  19. State: 0,
  20. }}, 3)
  21. So(err, ShouldBeNil)
  22. fmt.Println(err)
  23. }))
  24. }
  25. func TestSearchAdminLog(t *testing.T) {
  26. Convey("test search adminlog", t, WithDao(func(d *Dao) {
  27. res, err := d.SearchAdminLog(context.TODO(), []int64{111843721})
  28. So(err, ShouldBeNil)
  29. So(len(res), ShouldBeGreaterThan, 0)
  30. fmt.Printf("%+v", res[0])
  31. }))
  32. }
  33. func TestSearchMonitor(t *testing.T) {
  34. var (
  35. c = context.Background()
  36. sp = &model.SearchMonitorParams{
  37. Mode: 0,
  38. Type: 1,
  39. Oid: 10099866,
  40. Sort: "unverify_num",
  41. }
  42. oid int64 = 10099866
  43. typ int32 = 1
  44. remark = "remark"
  45. )
  46. Convey("test search monitor", t, WithDao(func(d *Dao) {
  47. res, err := d.SearchMonitor(c, sp, 1, 20)
  48. So(err, ShouldBeNil)
  49. So(len(res.Result), ShouldBeGreaterThan, 0)
  50. So(res.Result[0].Oid, ShouldEqual, sp.Oid)
  51. }))
  52. Convey("test add monitor", t, WithDao(func(d *Dao) {
  53. sub, _ := d.Subject(c, oid, typ)
  54. sub.AttrSet(model.AttrYes, model.SubAttrMonitor)
  55. err := d.UpSearchMonitor(c, sub, remark)
  56. So(err, ShouldBeNil)
  57. }))
  58. time.Sleep(5 * time.Second)
  59. Convey("test search monitor", t, WithDao(func(d *Dao) {
  60. res, err := d.SearchMonitor(c, sp, 1, 1)
  61. So(err, ShouldBeNil)
  62. So(len(res.Result), ShouldBeGreaterThan, 0)
  63. So(res.Result[0].Remark, ShouldEqual, remark)
  64. }))
  65. }