format_test.go 495 B

12345678910111213141516171819202122232425262728293031
  1. package file
  2. import (
  3. "testing"
  4. "gogs.baozhida.cn/zoie/OAuth-core/config/source"
  5. )
  6. func TestFormat(t *testing.T) {
  7. opts := source.NewOptions()
  8. e := opts.Encoder
  9. testCases := []struct {
  10. p string
  11. f string
  12. }{
  13. {"/foo/bar.json", "json"},
  14. {"/foo/bar.yaml", "yaml"},
  15. {"/foo/bar.xml", "xml"},
  16. {"/foo/bar.conf.ini", "ini"},
  17. {"conf", e.String()},
  18. }
  19. for _, d := range testCases {
  20. f := format(d.p, e)
  21. if f != d.f {
  22. t.Fatalf("%s: expected %s got %s", d.p, d.f, f)
  23. }
  24. }
  25. }