dm_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/job/main/dm/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestFlushTrimQueue(t *testing.T) {
  9. var (
  10. tp int32 = 1
  11. oid int64 = 1
  12. )
  13. Convey("", t, func() {
  14. err := testSvc.flushTrimQueue(context.TODO(), tp, oid)
  15. So(err, ShouldBeNil)
  16. })
  17. }
  18. func TestAddTrimQueue(t *testing.T) {
  19. var (
  20. tp int32 = 1
  21. oid int64 = 1
  22. maxlimit int64 = 1
  23. idx = &model.DM{ID: 1, Type: tp, Oid: oid, Mid: 1, Progress: 1, State: 0, Pool: 2, Attr: 1}
  24. )
  25. Convey("", t, func() {
  26. err := testSvc.addTrimQueue(context.TODO(), tp, oid, maxlimit, idx)
  27. So(err, ShouldBeNil)
  28. })
  29. }
  30. func TestRecoverDM(t *testing.T) {
  31. var (
  32. tp int32 = 1
  33. oid int64 = 1
  34. duration int64 = 10
  35. maxlimit int64 = 1
  36. sub = &model.Subject{ID: 1, Type: tp, Oid: oid, ACount: 2, Count: 2, Maxlimit: maxlimit}
  37. )
  38. Convey("", t, func() {
  39. _, err := testSvc.recoverDM(context.TODO(), sub.Type, sub.Oid, duration)
  40. So(err, ShouldBeNil)
  41. })
  42. }
  43. func TestSubject(t *testing.T) {
  44. var (
  45. tp int32 = 1
  46. oid int64 = 1
  47. )
  48. Convey("", t, func() {
  49. sub, err := testSvc.subject(context.TODO(), tp, oid)
  50. So(err, ShouldBeNil)
  51. So(sub, ShouldNotBeNil)
  52. })
  53. }