51 lines
729 B
Go
51 lines
729 B
Go
package conf
|
|
|
|
import (
|
|
`embed`
|
|
`encoding/xml`
|
|
`fmt`
|
|
"testing"
|
|
|
|
`github.com/BurntSushi/toml`
|
|
`github.com/goccy/go-yaml`
|
|
)
|
|
|
|
var (
|
|
//go:embed "_testdata"
|
|
testData embed.FS
|
|
)
|
|
|
|
func TestConf(t *testing.T) {
|
|
var err error
|
|
var cfg *Config
|
|
var b []byte
|
|
|
|
if b, err = testData.ReadFile("_testdata/test.json"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg, err = NewConfigFromBytes(b); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
/*
|
|
spew.Dump(cfg)
|
|
return
|
|
*/
|
|
|
|
if b, err = toml.Marshal(cfg); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fmt.Println(string(b))
|
|
|
|
if b, err = xml.MarshalIndent(cfg, "", " "); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fmt.Println(string(b))
|
|
|
|
if b, err = yaml.Marshal(cfg); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fmt.Println(string(b))
|
|
|
|
}
|