tss/app/schedule_test.go

29 lines
534 B
Go
Raw Normal View History

2022-04-27 00:19:05 -04:00
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"]))
}