service_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package feedback
  2. import (
  3. "context"
  4. "flag"
  5. "go-common/app/interface/main/creative/conf"
  6. "path/filepath"
  7. "testing"
  8. "time"
  9. . "github.com/smartystreets/goconvey/convey"
  10. "go-common/app/interface/main/creative/service"
  11. )
  12. var (
  13. s *Service
  14. )
  15. func init() {
  16. dir, _ := filepath.Abs("../../cmd/creative.toml")
  17. flag.Set("conf", dir)
  18. conf.Init()
  19. rpcdaos := service.NewRPCDaos(conf.Conf)
  20. s = New(conf.Conf, rpcdaos)
  21. time.Sleep(time.Second)
  22. }
  23. func WithService(f func(s *Service)) func() {
  24. return func() {
  25. Reset(func() {})
  26. f(s)
  27. }
  28. }
  29. func Test_State(t *testing.T) {
  30. var (
  31. c = context.TODO()
  32. mid = int64(2089809)
  33. )
  34. Convey("AppealList", t, WithService(func(s *Service) {
  35. _, err := s.Tags(c, mid, "")
  36. So(err, ShouldNotBeNil)
  37. }))
  38. Convey("Detail", t, WithService(func(s *Service) {
  39. _, err := s.Detail(c, mid, 23333, "")
  40. So(err, ShouldNotBeNil)
  41. }))
  42. Convey("Feedbacks", t, WithService(func(s *Service) {
  43. _, count, err := s.Feedbacks(c, mid, 10, 10, int64(2), "1", "2", "3", "pc", "")
  44. So(err, ShouldNotBeNil)
  45. So(count, ShouldBeZeroValue)
  46. }))
  47. }