cache_test.go 1016 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package cache
  2. import (
  3. "testing"
  4. "flag"
  5. "github.com/smartystreets/goconvey/convey"
  6. "go-common/app/admin/main/up/conf"
  7. "os"
  8. )
  9. func TestMain(m *testing.M) {
  10. if os.Getenv("DEPLOY_ENV") != "" {
  11. flag.Set("app_id", "main.archive.up-admin")
  12. flag.Set("conf_token", "930697bb7def4df0713ef8080596b863")
  13. flag.Set("tree_id", "36438")
  14. flag.Set("conf_version", "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/up-admin.toml")
  22. }
  23. if os.Getenv("UT_LOCAL_TEST") != "" {
  24. flag.Set("conf", "../../cmd/up-admin.toml")
  25. }
  26. flag.Parse()
  27. if err := conf.Init(); err != nil {
  28. panic(err)
  29. }
  30. os.Exit(m.Run())
  31. }
  32. func TestCacheLoadCache(t *testing.T) {
  33. convey.Convey("LoadCache", t, func(ctx convey.C) {
  34. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  35. LoadCache()
  36. ctx.Convey("No return values", func(ctx convey.C) {
  37. })
  38. })
  39. })
  40. }