From c2dd9a1fceb5da7694d1f02b976a20fd8161c67b Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 24 Jul 2014 13:44:31 -0700 Subject: [PATCH] schema: add test of time.ParseInLocation with UnknownLocation Change-Id: I23c1007b53d794e36e9eeaad03e9d11a4cd3c397 --- pkg/schema/schema_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/schema/schema_test.go b/pkg/schema/schema_test.go index 1c59f2ad8..582fa6df0 100644 --- a/pkg/schema/schema_test.go +++ b/pkg/schema/schema_test.go @@ -158,6 +158,21 @@ func TestStringFromMixedArray(t *testing.T) { } } +func TestParseInLocation_UnknownLocation(t *testing.T) { + // Example of parsing a time from an API (e.g. Flickr) that + // doesn't know its timezone. + const format = "2006-01-02 15:04:05" + const when = "2010-11-12 13:14:15" + tm, err := time.ParseInLocation(format, when, UnknownLocation) + if err != nil { + t.Fatal(err) + } + got, want := RFC3339FromTime(tm), "2010-11-12T13:14:15-00:01" + if got != want { + t.Errorf("parsed %v to %s; want %s", tm, got, want) + } +} + func TestIsZoneKnown(t *testing.T) { if !IsZoneKnown(time.Now()) { t.Errorf("should know Now's zone")