conf_test.go 474 B

12345678910111213141516171819202122232425262728293031323334
  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. [db.mongo]
  18. addr = "192.168.3.207:27092"
  19. dbname = "qfw"
  20. size = 10
  21. user = ""
  22. password = ""
  23. `
  24. func TestInit(t *testing.T) {
  25. testfile := "/tmp/crocodile.toml"
  26. ioutil.WriteFile(testfile, []byte(confs), 0644)
  27. Init(testfile)
  28. t.Logf("%+v", Conf.DB.Mongo.Addr)
  29. os.Remove(testfile)
  30. }