service_test.go 789 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "testing"
  6. "time"
  7. "go-common/app/job/main/member/conf"
  8. "go-common/app/job/main/member/model"
  9. "go-common/library/log"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. s *Service
  14. )
  15. func initConf() {
  16. if err := conf.Init(); err != nil {
  17. panic(err)
  18. }
  19. log.Init(conf.Conf.Xlog)
  20. defer log.Close()
  21. }
  22. func init() {
  23. flag.Set("conf", "../cmd/member-job-dev.toml")
  24. initConf()
  25. s = New(conf.Conf)
  26. }
  27. func TestAddexp(t *testing.T) {
  28. Convey("addexp", t, func() {
  29. err := s.addExp(context.Background(), &model.AddExp{Mid: 1})
  30. So(err, ShouldBeNil)
  31. })
  32. }
  33. func TestRecoverMoral(t *testing.T) {
  34. time.Sleep(time.Second * 2)
  35. Convey("recoverMoral", t, func() {
  36. err := s.recoverMoral(context.Background(), 2)
  37. So(err, ShouldBeNil)
  38. })
  39. }