github.com/annwntech/go-micro/v2@v2.9.5/config/source/file/format_test.go (about) 1 package file 2 3 import ( 4 "testing" 5 6 "github.com/annwntech/go-micro/v2/config/source" 7 ) 8 9 func TestFormat(t *testing.T) { 10 opts := source.NewOptions() 11 e := opts.Encoder 12 13 testCases := []struct { 14 p string 15 f string 16 }{ 17 {"/foo/bar.json", "json"}, 18 {"/foo/bar.yaml", "yaml"}, 19 {"/foo/bar.xml", "xml"}, 20 {"/foo/bar.conf.ini", "ini"}, 21 {"conf", e.String()}, 22 } 23 24 for _, d := range testCases { 25 f := format(d.p, e) 26 if f != d.f { 27 t.Fatalf("%s: expected %s got %s", d.p, d.f, f) 28 } 29 } 30 31 }