package app import ( "fmt" "testing" "time" "github.com/stretchr/testify/assert" "gopkg.in/yaml.v3" ) func TestYamlMap(t *testing.T) { 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"])) }