2019-05-30 23:11:13 +01:00
|
|
|
package file
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
"github.com/micro/go-micro/v3/config/source"
|
2019-05-30 23:11:13 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestFormat(t *testing.T) {
|
|
|
|
opts := source.NewOptions()
|
|
|
|
e := opts.Encoder
|
|
|
|
|
|
|
|
testCases := []struct {
|
|
|
|
p string
|
|
|
|
f string
|
|
|
|
}{
|
|
|
|
{"/foo/bar.json", "json"},
|
|
|
|
{"/foo/bar.yaml", "yaml"},
|
|
|
|
{"/foo/bar.xml", "xml"},
|
|
|
|
{"/foo/bar.conf.ini", "ini"},
|
|
|
|
{"conf", e.String()},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, d := range testCases {
|
|
|
|
f := format(d.p, e)
|
|
|
|
if f != d.f {
|
|
|
|
t.Fatalf("%s: expected %s got %s", d.p, d.f, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|