dao_test.go 1001 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package dao
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/job/main/search/conf"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. func WithDao(f func(d *Dao)) func() {
  11. return func() {
  12. dir, _ := filepath.Abs("../cmd/goconvey.toml")
  13. flag.Set("conf", dir)
  14. flag.Parse()
  15. conf.Init()
  16. d := New(conf.Conf)
  17. f(d)
  18. }
  19. }
  20. func Test_Reply(t *testing.T) {
  21. Convey("open app", t, WithDao(func(d *Dao) {
  22. var (
  23. err error
  24. c = context.TODO()
  25. )
  26. err = d.Ping(c)
  27. So(err, ShouldBeNil)
  28. }))
  29. }
  30. func Test_SetRecover(t *testing.T) {
  31. Convey("set recover", t, WithDao(func(d *Dao) {
  32. var (
  33. err error
  34. c = context.TODO()
  35. )
  36. d.SetRecover(c, "archive_video", 1000, "", 0)
  37. So(err, ShouldBeNil)
  38. }))
  39. }
  40. func Test_Close(t *testing.T) {
  41. Convey("test close", t, WithDao(func(d *Dao) {
  42. d.Close()
  43. }))
  44. }
  45. func Test_SendSMS(t *testing.T) {
  46. Convey("test send sms", t, WithDao(func(d *Dao) {
  47. var err error
  48. err = d.SendSMS("test sms")
  49. So(err, ShouldBeNil)
  50. }))
  51. }