1
0
mirror of https://github.com/TomWright/dasel.git synced 2022-05-22 02:32:45 +03:00

test: convert time.Time to toml representation properly

This commit is contained in:
egawata
2022-03-31 13:49:42 +09:00
parent 98123f6fa2
commit 1917f9e171

View File

@@ -5,6 +5,7 @@ import (
"reflect"
"strings"
"testing"
"time"
)
var tomlBytes = []byte(`names = ["John", "Frank"]
@@ -133,6 +134,19 @@ func TestTOMLParser_ToBytes(t *testing.T) {
}
exp := `asd
123
`
if exp != string(got) {
t.Errorf("expected:\n%s\ngot:\n%s", exp, got)
}
})
t.Run("time.Time", func(t *testing.T) {
v, _ := time.Parse(time.RFC3339, "2022-01-02T12:34:56Z")
got, err := (&storage.TOMLParser{}).ToBytes(v)
if err != nil {
t.Errorf("unexpected error: %s", err)
return
}
exp := `2022-01-02T12:34:56Z
`
if exp != string(got) {
t.Errorf("expected:\n%s\ngot:\n%s", exp, got)