service_test.go 605 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package service
  2. import (
  3. "flag"
  4. "path/filepath"
  5. "testing"
  6. "time"
  7. "go-common/app/job/main/creative/conf"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. var (
  11. s *Service
  12. )
  13. func init() {
  14. dir, _ := filepath.Abs("../cmd/creative-job.toml")
  15. flag.Set("conf", dir)
  16. conf.Init()
  17. s = New(conf.Conf)
  18. time.Sleep(time.Second)
  19. }
  20. func WithService(f func(s *Service)) func() {
  21. return func() {
  22. Reset(func() {})
  23. f(s)
  24. }
  25. }
  26. func Test_Pub(t *testing.T) {
  27. Convey("pub", t, WithService(func(s *Service) {
  28. Convey("pub", func() {
  29. err := s.pub(int64(2089809), 0, 1)
  30. So(err, ShouldBeNil)
  31. })
  32. }))
  33. }