config_offset_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package dao
  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/model"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. func WithCO(f func(d *Dao)) func() {
  12. return func() {
  13. dir, _ := filepath.Abs("../cmd/goconvey.toml")
  14. flag.Set("conf", dir)
  15. flag.Parse()
  16. conf.Init()
  17. d := New(conf.Conf)
  18. f(d)
  19. }
  20. }
  21. func Test_Offset(t *testing.T) {
  22. Convey("Test_Offset", t, WithCO(func(d *Dao) {
  23. var (
  24. err error
  25. c = context.TODO()
  26. )
  27. d.Offset(c, "", "")
  28. So(err, ShouldBeNil)
  29. }))
  30. }
  31. func Test_UpdateOffset(t *testing.T) {
  32. Convey("Test_UpdateOffset", t, WithCO(func(d *Dao) {
  33. var (
  34. err error
  35. c = context.TODO()
  36. offset = &model.LoopOffset{}
  37. )
  38. d.updateOffset(c, offset, "", "")
  39. So(err, ShouldBeNil)
  40. }))
  41. }
  42. func Test_BulkInitOffset(t *testing.T) {
  43. Convey("Test_BulkInitOffset", t, WithCO(func(d *Dao) {
  44. var (
  45. c = context.TODO()
  46. err error
  47. offset = &model.LoopOffset{}
  48. attrs = &model.Attrs{
  49. Table: &model.AttrTable{},
  50. }
  51. )
  52. attrs.Table.TableFrom = 0
  53. attrs.Table.TableTo = 0
  54. err = d.bulkInitOffset(c, offset, attrs, []string{})
  55. So(err, ShouldBeNil)
  56. }))
  57. }