service_test.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package service
  2. import (
  3. "context"
  4. "fmt"
  5. "sync"
  6. "testing"
  7. "time"
  8. "go-common/app/job/main/passport/conf"
  9. idfgmdl "go-common/app/service/main/identify-game/model"
  10. "go-common/library/log"
  11. . "github.com/smartystreets/goconvey/convey"
  12. )
  13. var (
  14. once sync.Once
  15. s *Service
  16. )
  17. func startService() {
  18. if err := conf.Init(); err != nil {
  19. panic(fmt.Sprintf("conf.Init() error(%v)", err))
  20. }
  21. // init log
  22. log.Init(conf.Conf.Xlog)
  23. s = New(conf.Conf)
  24. }
  25. func TestNew(t *testing.T) {
  26. once.Do(startService)
  27. Convey("new", t, func() {
  28. So(s.gameAppIDs[0], ShouldEqual, _gameAppID)
  29. t.Logf("s.gameAppIDs: %v", s.gameAppIDs)
  30. So(s.c.URI, ShouldNotBeNil)
  31. So(s.c.URI.DelCache, ShouldNotBeEmpty)
  32. So(s.c.URI.SetToken, ShouldNotBeEmpty)
  33. t.Logf("s.c.URI: %+v", s.c.URI)
  34. })
  35. }
  36. func TestDelCache(t *testing.T) {
  37. once.Do(startService)
  38. time.Sleep(time.Second * 1)
  39. Convey("del cache", t, func() {
  40. arg := &idfgmdl.CleanCacheArgs{
  41. Token: "foo",
  42. }
  43. err := s.igRPC.DelCache(context.Background(), arg)
  44. So(err, ShouldBeNil)
  45. })
  46. }