config_env_test.go 801 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package dns
  2. import (
  3. "github.com/0xJacky/Nginx-UI/internal/cert/config"
  4. "github.com/BurntSushi/toml"
  5. "log"
  6. "path/filepath"
  7. "testing"
  8. )
  9. func CheckIfErr(err error) {
  10. if err != nil {
  11. log.Fatalln(err)
  12. }
  13. }
  14. func TestConfigEnv(t *testing.T) {
  15. files, err := config.DistFS.ReadDir(".")
  16. CheckIfErr(err)
  17. for _, file := range files {
  18. if filepath.Ext(file.Name()) != ".toml" {
  19. continue
  20. }
  21. c := Config{}
  22. _, err := toml.DecodeFS(config.DistFS, file.Name(), &c)
  23. CheckIfErr(err)
  24. log.Println(c.Name)
  25. if c.Configuration != nil {
  26. for k, v := range c.Configuration.Credentials {
  27. log.Println(k, v)
  28. }
  29. for k, v := range c.Configuration.Additional {
  30. log.Println(k, v)
  31. }
  32. }
  33. if c.Links != nil {
  34. log.Println(c.Links.API)
  35. log.Println(c.Links.GoClient)
  36. }
  37. }
  38. }