service_test.go 620 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/job/main/stat/conf"
  8. "go-common/app/service/main/archive/api"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. s *Service
  13. )
  14. func init() {
  15. dir, _ := filepath.Abs("../cmd/stat-job-test.toml")
  16. flag.Set("conf", dir)
  17. conf.Init()
  18. s = New(conf.Conf)
  19. }
  20. func Test_Ping(t *testing.T) {
  21. Convey("Ping", t, func() {
  22. s.Ping(context.TODO())
  23. })
  24. }
  25. func Test_UpdateCache(t *testing.T) {
  26. Convey("updateCache", t, func() {
  27. err := s.updateCache(&api.Stat{
  28. Aid: 1,
  29. Coin: 22,
  30. View: 200,
  31. })
  32. So(err, ShouldBeNil)
  33. })
  34. }