tss/app/config_test.go

42 lines
858 B
Go
Raw Normal View History

2022-04-28 19:24:21 -04:00
package app
import (
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
)
var contents = []byte(`
data_dir: blah
feeds:
- url: "https://balki.me"
name: "Blah"
- url: "https://blue.balki.me"
name: "sldkfj Blah"
`)
func TestConfigParse(t *testing.T) {
c := Config{}
err := yaml.Unmarshal(contents, &c)
assert.NoError(t, err)
assert.Equal(t, "blah", c.DataDir)
/*
yesterday := time.Now().Add(-24 * time.Hour)
m := map[string]time.Time{
"Bala": time.Now(),
"Linus": yesterday,
}
out, err := yaml.Marshal(&m)
if err != nil {
t.Fatalf("got err: %v", err)
}
// assert.Equal(t, nil, fmt.Sprintf("%s", out))
var m2 map[string]time.Time
err = yaml.Unmarshal(out, &m2)
assert.NoError(t, err)
assert.Equal(t, "foobar", fmt.Sprint(m2["Bala"]))
*/
}