service_test.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package elec
  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("ArchiveState", t, WithService(func(s *Service) {
  35. _, err := s.ArchiveState(c, 2333, mid, "")
  36. So(err, ShouldBeNil)
  37. }))
  38. Convey("UserState", t, WithService(func(s *Service) {
  39. _, err := s.UserState(c, mid, "", "", "")
  40. So(err, ShouldBeNil)
  41. }))
  42. Convey("UserInfo", t, WithService(func(s *Service) {
  43. _, err := s.UserInfo(c, mid, "")
  44. So(err, ShouldBeNil)
  45. }))
  46. Convey("Notify", t, WithService(func(s *Service) {
  47. _, err := s.Notify(c, "")
  48. So(err, ShouldBeNil)
  49. }))
  50. Convey("Status", t, WithService(func(s *Service) {
  51. _, err := s.Status(c, mid, "")
  52. So(err, ShouldBeNil)
  53. }))
  54. Convey("UpStatus", t, WithService(func(s *Service) {
  55. err := s.UpStatus(c, mid, 1, "")
  56. So(err, ShouldBeNil)
  57. }))
  58. Convey("RecentRank", t, WithService(func(s *Service) {
  59. _, err := s.RecentRank(c, mid, 10, "")
  60. So(err, ShouldBeNil)
  61. }))
  62. Convey("CurrentRank", t, WithService(func(s *Service) {
  63. _, err := s.CurrentRank(c, mid, "")
  64. So(err, ShouldBeNil)
  65. }))
  66. Convey("TotalRank", t, WithService(func(s *Service) {
  67. _, err := s.TotalRank(c, mid, "")
  68. So(err, ShouldBeNil)
  69. }))
  70. Convey("Balance", t, WithService(func(s *Service) {
  71. _, err := s.Balance(c, mid, "")
  72. So(err, ShouldBeNil)
  73. }))
  74. Convey("RemarkDetail", t, WithService(func(s *Service) {
  75. _, err := s.RemarkDetail(c, mid, 233, "")
  76. So(err, ShouldBeNil)
  77. }))
  78. }