promote_test.go 862 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package operation
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/web-show/conf"
  9. rsmdl "go-common/app/interface/main/web-show/model/operation"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var svf *Service
  13. func init() {
  14. dir, _ := filepath.Abs("../../cmd/web-show-test.toml")
  15. flag.Set("conf", dir)
  16. if err := conf.Init(); err != nil {
  17. panic(err)
  18. }
  19. if svf == nil {
  20. svf = New(conf.Conf)
  21. }
  22. time.Sleep(time.Second)
  23. }
  24. func WithService(f func(s *Service)) func() {
  25. return func() {
  26. f(svf)
  27. }
  28. }
  29. func TestService_Resource(t *testing.T) {
  30. Convey("should return without err", t, WithService(func(svf *Service) {
  31. arg := &rsmdl.ArgPromote{
  32. Tp: "test",
  33. Count: 1,
  34. Rank: 1,
  35. }
  36. res, err := svf.Promote(context.TODO(), arg)
  37. So(err, ShouldBeNil)
  38. So(len(res), ShouldBeGreaterThan, 0)
  39. }))
  40. }