conf_test.go 501 B

123456789101112131415161718192021222324252627282930
  1. package config
  2. import (
  3. "io/ioutil"
  4. "os"
  5. "testing"
  6. )
  7. var confs = `# log
  8. [log]
  9. logpath = ""
  10. maxsize = 10
  11. compress = true
  12. maxage = 7
  13. maxbackups = 10
  14. loglevel = "info"
  15. format = "text"
  16. [db]
  17. drivename = "mysql"
  18. dsn = "root:=PDT49#80Z!RVv52_z@tcp(192.168.3.217:4000)/crocodile?charset=utf8mb4&parseTime=True&loc=Local"
  19. `
  20. func TestInit(t *testing.T) {
  21. testfile := "/tmp/crocodile.toml"
  22. ioutil.WriteFile(testfile, []byte(confs), 0644)
  23. Init(testfile)
  24. t.Logf("%+v", Conf.DB)
  25. os.Remove(testfile)
  26. }