dao_test.go 645 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package activity
  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. "go-common/app/job/main/videoup/model/archive"
  10. )
  11. var (
  12. d *Dao
  13. )
  14. func init() {
  15. dir, _ := filepath.Abs("../../cmd/videoup-job-test.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. f(d)
  23. }
  24. }
  25. func Test_AddVideo(t *testing.T) {
  26. var (
  27. c = context.TODO()
  28. a = new(archive.Archive)
  29. err error
  30. )
  31. Convey("AddVideo", t, WithDao(func(d *Dao) {
  32. err = d.AddVideo(c, a, 10086)
  33. So(err, ShouldBeNil)
  34. }))
  35. }