service_test.go 930 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "go-common/app/admin/main/creative/conf"
  9. accapi "go-common/app/service/main/account/api"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. s *Service
  14. )
  15. func init() {
  16. dir, _ := filepath.Abs("../cmd/creative-admin.toml")
  17. flag.Set("conf", dir)
  18. conf.Init()
  19. s = New(conf.Conf)
  20. time.Sleep(time.Second)
  21. }
  22. func WithService(f func(s *Service)) func() {
  23. return func() {
  24. Reset(func() {})
  25. f(s)
  26. }
  27. }
  28. func Test_Profile(t *testing.T) {
  29. mid := int64(27515256)
  30. Convey("Profile", t, WithService(func(s *Service) {
  31. var (
  32. pfl *accapi.ProfileStatReply
  33. err error
  34. )
  35. pfl, err = s.ProfileStat(context.TODO(), mid)
  36. time.Sleep(time.Millisecond * 100)
  37. So(err, ShouldBeNil)
  38. So(pfl, ShouldNotBeNil)
  39. }))
  40. }
  41. func Test_SearchKeywords(t *testing.T) {
  42. Convey("SearchKeywords", t, WithService(func(s *Service) {
  43. s.SearchKeywords()
  44. }))
  45. }