service_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package block
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "go-common/app/admin/main/member/conf"
  8. "go-common/app/admin/main/member/model/block"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. s *Service
  13. c = context.Background()
  14. )
  15. func TestMain(m *testing.M) {
  16. defer os.Exit(0)
  17. flag.Set("conf", "../cmd/member-admin-test.toml")
  18. var err error
  19. if err = conf.Init(); err != nil {
  20. panic(err)
  21. }
  22. m.Run()
  23. }
  24. func TestService(t *testing.T) {
  25. Convey("", t, func() {
  26. s.Ping(c)
  27. s.Close()
  28. })
  29. }
  30. func TestBlock(t *testing.T) {
  31. Convey("block", t, func() {
  32. var (
  33. p = &block.ParamBatchBlock{
  34. MIDs: []int64{1, 2, 3, 4},
  35. AdminID: 233,
  36. AdminName: "233",
  37. Source: 1,
  38. Area: block.BlockAreaNone,
  39. Reason: "test",
  40. Comment: "test",
  41. Action: block.BlockActionLimit,
  42. Duration: 1,
  43. Notify: false,
  44. }
  45. pm = &block.ParamBatchRemove{
  46. MIDs: []int64{1, 2, 3, 4},
  47. AdminID: 233,
  48. AdminName: "233",
  49. Comment: "test",
  50. Notify: false,
  51. }
  52. )
  53. err := s.BatchBlock(c, p)
  54. So(err, ShouldBeNil)
  55. err = s.BatchRemove(c, pm)
  56. So(err, ShouldBeNil)
  57. })
  58. }