resource_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package global
  2. import (
  3. "flag"
  4. "os"
  5. "testing"
  6. "go-common/app/interface/main/mcn/conf"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestMain(m *testing.M) {
  10. if os.Getenv("DEPLOY_ENV") != "" {
  11. flag.Set("app_id", "main.archive.mcn-interface")
  12. flag.Set("conf_token", "49e4671bafbf93059aeb602685052ca0")
  13. flag.Set("tree_id", "58909")
  14. flag.Set("conf_version", "docker-1")
  15. flag.Set("deploy_env", "uat")
  16. flag.Set("conf_host", "config.bilibili.co")
  17. flag.Set("conf_path", "/tmp")
  18. flag.Set("region", "sh")
  19. flag.Set("zone", "sh001")
  20. } else {
  21. flag.Set("conf", "../../cmd/mcn-interface.toml")
  22. }
  23. if os.Getenv("UT_LOCAL_TEST") != "" {
  24. flag.Set("conf", "../../cmd/mcn-interface.toml")
  25. }
  26. flag.Parse()
  27. if err := conf.Init(); err != nil {
  28. panic(err)
  29. }
  30. Init(conf.Conf)
  31. os.Exit(m.Run())
  32. }
  33. func TestGlobalGetAccGRPC(t *testing.T) {
  34. convey.Convey("GetAccGRPC", t, func(ctx convey.C) {
  35. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  36. p1 := GetAccGRPC()
  37. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  38. ctx.So(p1, convey.ShouldNotBeNil)
  39. })
  40. })
  41. })
  42. }
  43. func TestGlobalGetMemGRPC(t *testing.T) {
  44. convey.Convey("GetMemGRPC", t, func(ctx convey.C) {
  45. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  46. p1 := GetMemGRPC()
  47. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  48. ctx.So(p1, convey.ShouldNotBeNil)
  49. })
  50. })
  51. })
  52. }
  53. func TestGlobalGetArcGRPC(t *testing.T) {
  54. convey.Convey("GetArcGRPC", t, func(ctx convey.C) {
  55. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  56. p1 := GetArcGRPC()
  57. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  58. ctx.So(p1, convey.ShouldNotBeNil)
  59. })
  60. })
  61. })
  62. }