From 1917f9e171391daf678fbc35489cdbfbbc36b529 Mon Sep 17 00:00:00 2001 From: egawata Date: Thu, 31 Mar 2022 13:49:42 +0900 Subject: [PATCH] test: convert time.Time to toml representation properly --- storage/toml_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/storage/toml_test.go b/storage/toml_test.go index 9f7d133..f6e2b9c 100644 --- a/storage/toml_test.go +++ b/storage/toml_test.go @@ -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)