business_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package business
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/job/main/search/conf"
  8. "go-common/app/job/main/search/dao"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. func WithBusinessArv(f func(d *Avr)) func() {
  12. return func() {
  13. dir, _ := filepath.Abs("../dao/cmd/goconvey.toml")
  14. flag.Set("conf", dir)
  15. flag.Parse()
  16. conf.Init()
  17. d := dao.New(conf.Conf)
  18. bsn := NewAvr(d, "archive_video", conf.Conf)
  19. f(bsn)
  20. }
  21. }
  22. func Test_AvrRecover(t *testing.T) {
  23. Convey("set recover", t, WithBusinessArv(func(d *Avr) {
  24. var (
  25. err error
  26. c = context.TODO()
  27. )
  28. d.SetRecover(c, 1000, "", 0)
  29. So(err, ShouldBeNil)
  30. }))
  31. }
  32. func Test_AvrInitOffset(t *testing.T) {
  33. Convey("test close", t, WithBusinessArv(func(d *Avr) {
  34. d.InitOffset(context.TODO())
  35. }))
  36. }
  37. func WithBusinessDmDate(f func(d *DmDate)) func() {
  38. return func() {
  39. dir, _ := filepath.Abs("../dao/cmd/goconvey.toml")
  40. flag.Set("conf", dir)
  41. flag.Parse()
  42. conf.Init()
  43. d := dao.New(conf.Conf)
  44. bsn := NewDmDate(d, "dm_search")
  45. f(bsn)
  46. }
  47. }
  48. func Test_DmDateRecover(t *testing.T) {
  49. Convey("set recover", t, WithBusinessDmDate(func(d *DmDate) {
  50. var (
  51. err error
  52. c = context.TODO()
  53. )
  54. d.SetRecover(c, 1000, "", 0)
  55. So(err, ShouldBeNil)
  56. }))
  57. }
  58. func Test_DmDateInitOffset(t *testing.T) {
  59. Convey("test close", t, WithBusinessDmDate(func(d *DmDate) {
  60. d.InitOffset(context.TODO())
  61. }))
  62. }
  63. func WithBusinessLog(f func(d *Log)) func() {
  64. return func() {
  65. dir, _ := filepath.Abs("../dao/cmd/goconvey.toml")
  66. flag.Set("conf", dir)
  67. flag.Parse()
  68. conf.Init()
  69. d := dao.New(conf.Conf)
  70. bsn := NewLog(d, "log_audit")
  71. f(bsn)
  72. }
  73. }
  74. func Test_LogRecover(t *testing.T) {
  75. Convey("set recover", t, WithBusinessLog(func(d *Log) {
  76. var (
  77. err error
  78. c = context.TODO()
  79. )
  80. d.SetRecover(c, 1000, "", 0)
  81. So(err, ShouldBeNil)
  82. }))
  83. }
  84. func Test_LogInitOffset(t *testing.T) {
  85. Convey("test close", t, WithBusinessLog(func(d *Log) {
  86. d.InitOffset(context.TODO())
  87. }))
  88. }
  89. func Test_LogInitIndex(t *testing.T) {
  90. Convey("test init index", t, WithBusinessLog(func(d *Log) {
  91. d.InitIndex(context.TODO())
  92. }))
  93. }
  94. func Test_LogOffset(t *testing.T) {
  95. Convey("test offset", t, WithBusinessLog(func(d *Log) {
  96. d.Offset(context.TODO())
  97. }))
  98. }
  99. func Test_LogSetRecover(t *testing.T) {
  100. Convey("test set recover", t, WithBusinessLog(func(d *Log) {
  101. d.SetRecover(context.TODO(), 0, "", 0)
  102. }))
  103. }
  104. func Test_LogAllMessages(t *testing.T) {
  105. Convey("test set recover", t, WithBusinessLog(func(d *Log) {
  106. d.AllMessages(context.TODO())
  107. }))
  108. }