service_test.go 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package service
  2. import (
  3. "flag"
  4. "path/filepath"
  5. "testing"
  6. "time"
  7. "go-common/app/admin/main/tv/conf"
  8. "fmt"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. srv *Service
  13. )
  14. func init() {
  15. dir, _ := filepath.Abs("../cmd/tv-admin-test.toml")
  16. flag.Set("conf", dir)
  17. conf.Init()
  18. srv = New(conf.Conf)
  19. time.Sleep(time.Second)
  20. }
  21. func WithService(f func(s *Service)) func() {
  22. return func() {
  23. Reset(func() {})
  24. f(srv)
  25. }
  26. }
  27. func Test_existArcTypes(t *testing.T) {
  28. Convey("existArcTs", t, WithService(func(s *Service) {
  29. exist, err := s.existArcTps(true)
  30. fmt.Println(exist)
  31. fmt.Println(err)
  32. So(err, ShouldBeNil)
  33. exist, err = s.existArcTps(false)
  34. fmt.Println(exist)
  35. fmt.Println(err)
  36. So(err, ShouldBeNil)
  37. }))
  38. }
  39. func Test_Wait(t *testing.T) {
  40. Convey("wait all closed", t, WithService(func(s *Service) {
  41. s.Wait()
  42. }))
  43. }
  44. func TestService_ResExist(t *testing.T) {
  45. Convey("res exist", t, WithService(func(s *Service) {
  46. fmt.Println(s.resExist(255, 1))
  47. fmt.Println(s.recomExist(2))
  48. }))
  49. }