config_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package apollo
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. var config = new(Config)
  7. type Config struct {
  8. MySQL struct {
  9. Read struct {
  10. Addr string `yaml:"addr"`
  11. User string `yaml:"user"`
  12. Pass string `yaml:"pass"`
  13. Name string `yaml:"name"`
  14. } `yaml:"read"`
  15. Write struct {
  16. Addr string `yaml:"addr"`
  17. User string `yaml:"user"`
  18. Pass string `yaml:"pass"`
  19. Name string `yaml:"name"`
  20. } `yaml:"write"`
  21. Base struct {
  22. MaxOpenConn int `yaml:"maxOpenConn"`
  23. MaxIdleConn int `yaml:"maxIdleConn"`
  24. ConnMaxLifeTime time.Duration `yaml:"connMaxLifeTime"`
  25. } `yaml:"base"`
  26. } `yaml:"mysql"`
  27. Redis struct {
  28. Addr string `yaml:"addr"`
  29. Pass string `yaml:"pass"`
  30. Db int `yaml:"db"`
  31. MaxRetries int `yaml:"maxRetries"`
  32. PoolSize int `yaml:"poolSize"`
  33. MinIdleConns int `yaml:"minIdleConns"`
  34. } `yaml:"redis"`
  35. Mail struct {
  36. Host string `yaml:"host"`
  37. Port int `yaml:"port"`
  38. User string `yaml:"user"`
  39. Pass string `yaml:"pass"`
  40. To string `yaml:"to"`
  41. } `yaml:"mail"`
  42. JWT struct {
  43. Secret string `yaml:"secret"`
  44. ExpireDuration time.Duration `yaml:"expireDuration"`
  45. } `yaml:"jwt"`
  46. URLToken struct {
  47. Secret string `yaml:"secret"`
  48. ExpireDuration time.Duration `yaml:"expireDuration"`
  49. } `yaml:"urlToken"`
  50. HashIds struct {
  51. Secret string `yaml:"secret"`
  52. Length int `yaml:"length"`
  53. } `yaml:"hashids"`
  54. }
  55. func TestGetApolloConfig(t *testing.T) {
  56. GetApolloConfig("authentication-sever", "269623f320014ce393971763ef2025ed", config)
  57. }