service_test.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "go-common/app/admin/main/growup/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. s *Service
  13. )
  14. func init() {
  15. dir, _ := filepath.Abs("../cmd/growup-admin.toml")
  16. flag.Set("conf", dir)
  17. conf.Init()
  18. s = New(conf.Conf)
  19. time.Sleep(time.Second)
  20. }
  21. func TestService_AddUpInfo(t *testing.T) {
  22. Convey("AddUpInfo", t, WithService(func(s *Service) {
  23. err := s.AddUp(context.Background(), 11, 2)
  24. So(err, ShouldBeNil)
  25. }))
  26. }
  27. func TestService_Block(t *testing.T) {
  28. Convey("Block", t, WithService(func(s *Service) {
  29. err := s.Block(context.Background(), 11)
  30. So(err, ShouldBeNil)
  31. }))
  32. }
  33. func TestService_DeleteFromBlocked(t *testing.T) {
  34. Convey("DeleteFromBlocked", t, WithService(func(s *Service) {
  35. err := s.DeleteFromBlocked(context.Background(), 11)
  36. So(err, ShouldBeNil)
  37. }))
  38. }
  39. func TestService_DeleteUp(t *testing.T) {
  40. Convey("DeleteUp", t, WithService(func(s *Service) {
  41. err := s.DeleteUp(context.Background(), 11)
  42. So(err, ShouldBeNil)
  43. }))
  44. }
  45. func TestService_Pass(t *testing.T) {
  46. Convey("Pass", t, WithService(func(s *Service) {
  47. err := s.Pass(context.Background(), []int64{11}, 0)
  48. So(err, ShouldBeNil)
  49. }))
  50. }
  51. func TestService_QueryFromBlocked(t *testing.T) {
  52. Convey("QueryFromBlocked", t, WithService(func(s *Service) {
  53. _, _, err := s.QueryFromBlocked(context.Background(), 0, 0, "", 0, 0, 0, 0, "mid")
  54. So(err, ShouldBeNil)
  55. }))
  56. }
  57. func TestService_QueryFromUpInfo(t *testing.T) {
  58. Convey("", t, WithService(func(s *Service) {
  59. _, _, err := s.QueryFromUpInfo(context.Background(), 0, 1, nil, 0, 1, 0, "", 0, 0, 1, 1, "-mid")
  60. So(err, ShouldBeNil)
  61. }))
  62. }
  63. func TestService_Recovery(t *testing.T) {
  64. Convey("Recovery", t, WithService(func(s *Service) {
  65. err := s.Recovery(context.Background(), 11)
  66. So(err, ShouldBeNil)
  67. }))
  68. }
  69. func TestService_Reject(t *testing.T) {
  70. Convey("Reject", t, WithService(func(s *Service) {
  71. mids := []int64{11}
  72. err := s.Reject(context.Background(), 0, mids, "违规", 1)
  73. So(err, ShouldBeNil)
  74. }))
  75. }
  76. func TestService_DelUpAccount(t *testing.T) {
  77. Convey("DelUpAccount", t, WithService(func(s *Service) {
  78. err := s.DelUpAccount(context.Background(), 11)
  79. So(err, ShouldBeNil)
  80. }))
  81. }