GoBroke/conf/funcs_test.go

51 lines
729 B
Go
Raw Normal View History

2024-12-17 17:39:10 -05:00
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))
}