unicom_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package unicom
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "go-common/app/job/main/app-wall/conf"
  9. "go-common/app/job/main/app-wall/model/unicom"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. s *Service
  14. )
  15. func WithService(f func(s *Service)) func() {
  16. return func() {
  17. f(s)
  18. }
  19. }
  20. func init() {
  21. dir, _ := filepath.Abs("../../cmd/app-wall-job-test.toml")
  22. flag.Set("conf", dir)
  23. conf.Init()
  24. s = New(conf.Conf)
  25. time.Sleep(time.Second)
  26. }
  27. func TestAddUserPackLogproc(t *testing.T) {
  28. Convey("Unicom addUserPackLogproc", t, WithService(func(s *Service) {
  29. s.addUserPackLogproc()
  30. }))
  31. }
  32. func TestAddUserIntegralLogproc(t *testing.T) {
  33. Convey("Unicom addUserIntegralLogproc", t, WithService(func(s *Service) {
  34. s.addUserIntegralLogproc(1)
  35. }))
  36. }
  37. func TestAddUserIntegralLog(t *testing.T) {
  38. Convey("Unicom addUserIntegralLog", t, WithService(func(s *Service) {
  39. s.addUserIntegralLog(&unicom.UserIntegralLog{})
  40. }))
  41. }
  42. func TestLoadUnicomIP(t *testing.T) {
  43. Convey("Unicom loadUnicomIP", t, WithService(func(s *Service) {
  44. s.loadUnicomIP(context.TODO())
  45. }))
  46. }
  47. func TestLoadUnicomIPOrder(t *testing.T) {
  48. Convey("Unicom loadUnicomIPOrder", t, WithService(func(s *Service) {
  49. s.loadUnicomIPOrder(time.Now())
  50. }))
  51. }