service_test.go 901 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "fmt"
  6. "path/filepath"
  7. "testing"
  8. "go-common/app/job/main/favorite/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. s *Service
  13. )
  14. func init() {
  15. dir, _ := filepath.Abs("../cmd/favorite-job-test.toml")
  16. flag.Set("conf", dir)
  17. err := conf.Init()
  18. if err != nil {
  19. fmt.Printf("conf.Init() error(%v)", err)
  20. }
  21. s = New(conf.Conf)
  22. }
  23. func Test_archiveRPC(t *testing.T) {
  24. Convey("archiveRPC", t, func() {
  25. var (
  26. aid int64 = 123
  27. )
  28. res, err := s.archiveRPC(context.TODO(), aid)
  29. t.Logf("res:%+v", res)
  30. t.Logf("err:%v", err)
  31. So(res, ShouldNotBeNil)
  32. So(err, ShouldBeNil)
  33. })
  34. }
  35. func Test_ArcsRPC(t *testing.T) {
  36. Convey("ArcsRPC", t, func() {
  37. var (
  38. aids = []int64{123, 456}
  39. )
  40. res, err := s.ArcsRPC(context.TODO(), aids)
  41. t.Logf("res:%+v", res)
  42. t.Logf("err:%v", err)
  43. So(res, ShouldNotBeNil)
  44. So(err, ShouldBeNil)
  45. })
  46. }