dao_test.go 587 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package message
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. . "github.com/smartystreets/goconvey/convey"
  8. "go-common/app/job/main/videoup/conf"
  9. )
  10. var (
  11. d *Dao
  12. )
  13. func init() {
  14. dir, _ := filepath.Abs("../../cmd/videoup-job-test.toml")
  15. flag.Set("conf", dir)
  16. conf.Init()
  17. d = New(conf.Conf)
  18. }
  19. func WithDao(f func(d *Dao)) func() {
  20. return func() {
  21. f(d)
  22. }
  23. }
  24. func Test_PushMsg(t *testing.T) {
  25. var (
  26. c = context.TODO()
  27. err error
  28. )
  29. Convey("PushMsg", t, WithDao(func(d *Dao) {
  30. err = d.PushMsg(c, 10086, "test-title", "test-msg")
  31. So(err, ShouldBeNil)
  32. }))
  33. }