dao_test.go 748 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package mission
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/job/main/videoup-report/conf"
  8. "go-common/app/job/main/videoup-report/model/mission"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. d *Dao
  13. )
  14. func init() {
  15. dir, _ := filepath.Abs("../../cmd/videoup-report-job.toml")
  16. flag.Set("conf", dir)
  17. conf.Init()
  18. d = New(conf.Conf)
  19. }
  20. func WithDao(f func(d *Dao)) func() {
  21. return func() {
  22. Reset(func() {})
  23. f(d)
  24. }
  25. }
  26. func Test_Missions(t *testing.T) {
  27. var (
  28. c = context.TODO()
  29. err error
  30. mm map[int]*mission.Mission
  31. )
  32. Convey("Missions", t, WithDao(func(d *Dao) {
  33. mm, err = d.Missions(c)
  34. So(err, ShouldBeNil)
  35. So(mm, ShouldNotBeNil)
  36. So(len(mm), ShouldBeGreaterThanOrEqualTo, 0)
  37. }))
  38. }