dm_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/dm/model"
  6. "github.com/davecgh/go-spew/spew"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDMSearch(t *testing.T) {
  10. d := &model.SearchDMParams{
  11. Type: 1,
  12. Oid: 1,
  13. Mid: model.CondIntNil,
  14. ProgressFrom: model.CondIntNil,
  15. ProgressTo: model.CondIntNil,
  16. CtimeFrom: model.CondIntNil,
  17. CtimeTo: model.CondIntNil,
  18. State: "",
  19. Pool: "",
  20. Page: 1,
  21. Order: "id",
  22. Sort: "asc",
  23. }
  24. Convey("test dm list", t, func() {
  25. res, err := svr.DMSearch(context.TODO(), d)
  26. So(err, ShouldBeNil)
  27. So(res, ShouldNotBeNil)
  28. spew.Dump(res)
  29. So(res.Result, ShouldNotBeEmpty)
  30. })
  31. }
  32. func TestEditDMPool(t *testing.T) {
  33. Convey("test change pool id", t, func() {
  34. err := svr.EditDMPool(context.TODO(), 1, 1, 1, []int64{1, 2}, 123)
  35. So(err, ShouldBeNil)
  36. })
  37. }
  38. func TestXMLCacheFlush(t *testing.T) {
  39. Convey("test flush cache", t, func() {
  40. svr.XMLCacheFlush(context.TODO(), 1, 1221)
  41. })
  42. }
  43. func TestEditDMState(t *testing.T) {
  44. dmids := []int64{1, 2}
  45. Convey("test content status", t, func() {
  46. res := svr.EditDMState(context.TODO(), 1, 1221, 1, 1, dmids, 10, 123, "admin", "test")
  47. So(res, ShouldNotBeNil)
  48. })
  49. }
  50. func TestEditDMAttr(t *testing.T) {
  51. Convey("test change attr", t, func() {
  52. err := svr.EditDMAttr(context.TODO(), 1, 1, []int64{1, 2}, model.AttrProtect, 1, 123)
  53. So(err, ShouldBeNil)
  54. })
  55. }
  56. func TestDMIndexInfo(t *testing.T) {
  57. var cid int64 = 9967205
  58. Convey("test dm index info", t, func() {
  59. idx, err := svr.DMIndexInfo(context.TODO(), cid)
  60. So(err, ShouldBeNil)
  61. So(idx, ShouldNotBeNil)
  62. })
  63. }