resource_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package global
  2. import (
  3. "flag"
  4. "os"
  5. "testing"
  6. "go-common/app/admin/main/up-rating/conf"
  7. "go-common/library/net/rpc"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestGlobalInit(t *testing.T) {
  11. convey.Convey("Init", t, func(ctx convey.C) {
  12. var (
  13. c = &conf.Config{RPCClient: &conf.RPCClient{Account: &rpc.ClientConfig{}}}
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. Init(c)
  17. ctx.Convey("No return values", func(ctx convey.C) {
  18. })
  19. })
  20. })
  21. }
  22. func TestMain(m *testing.M) {
  23. if os.Getenv("DEPLOY_ENV") != "" {
  24. flag.Set("app_id", "main.archive.up-rating-admin")
  25. flag.Set("conf_token", "15a509f907688750c0f2fceb768005f5")
  26. flag.Set("tree_id", "66972")
  27. flag.Set("conf_version", "docker-1")
  28. flag.Set("deploy_env", "uat")
  29. flag.Set("conf_host", "config.bilibili.co")
  30. flag.Set("conf_path", "/tmp")
  31. flag.Set("region", "sh")
  32. flag.Set("zone", "sh001")
  33. } else {
  34. flag.Set("conf", "../../cmd/up-rating-admin.toml")
  35. }
  36. flag.Parse()
  37. if err := conf.Init(); err != nil {
  38. panic(err)
  39. }
  40. Init(conf.Conf)
  41. os.Exit(m.Run())
  42. }