diff options
author | Lukasz Wojciechowski <l.wojciechow@partner.samsung.com> | 2018-11-22 11:39:46 +0100 |
---|---|---|
committer | Lukasz Wojciechowski <l.wojciechow@partner.samsung.com> | 2018-11-22 14:21:51 +0100 |
commit | 2806c69d6b6cbe05bc68b6e485e54b3aad0ce462 (patch) | |
tree | 20cad4fff459fe13e5b71b9caef08bf200737670 | |
parent | 002353a8cd24a6c317819c5b0df78f73d21f4f2e (diff) | |
download | slav-2806c69d6b6cbe05bc68b6e485e54b3aad0ce462.tar.gz slav-2806c69d6b6cbe05bc68b6e485e54b3aad0ce462.tar.bz2 slav-2806c69d6b6cbe05bc68b6e485e54b3aad0ce462.zip |
Fix SerializerText timestamp tests
The time variables used for tests were defined in local timezone.
On different machines the output of timestamp serialization was also
in different timezones.
This was fixed to use UTC timezone for that test.
To cover also serilization in different timezones an additional test
was added to verify serialization in different timezones.
Change-Id: I69e9530006c425426f944d2591c8ae4a5e3713ce
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
-rw-r--r-- | logger/serializer_text_test.go | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/logger/serializer_text_test.go b/logger/serializer_text_test.go index efc18ad..60ed489 100644 --- a/logger/serializer_text_test.go +++ b/logger/serializer_text_test.go @@ -270,16 +270,33 @@ var _ = Describe("SerializerText", func() { T.DescribeTable("should serialize proper time when time stamp is set to Full", func(days int, expected string) { s.TimestampMode = TimestampModeFull - stamp := time.Unix(1234567890, 0).AddDate(0, 0, days) + stamp := time.Unix(1234567890, 0).AddDate(0, 0, days).UTC() err := s.appendTimestamp(buf, &stamp) Expect(err).NotTo(HaveOccurred()) Expect(buf.String()).To(Equal(expected)) }, - T.Entry("Day", 1, "[2009-02-15T00:31:30+01:00] "), - T.Entry("Week", 7, "[2009-02-21T00:31:30+01:00] "), - T.Entry("Month", 30, "[2009-03-16T00:31:30+01:00] "), - T.Entry("Year", 365, "[2010-02-14T00:31:30+01:00] "), + T.Entry("Day", 1, "[2009-02-14T23:31:30Z] "), + T.Entry("Week", 7, "[2009-02-20T23:31:30Z] "), + T.Entry("Month", 30, "[2009-03-15T23:31:30Z] "), + T.Entry("Year", 365, "[2010-02-13T23:31:30Z] "), + ) + T.DescribeTable("should serialize proper time stamp using different timezones", + func(zoneName string, expected string) { + loc, err := time.LoadLocation(zoneName) + Expect(err).NotTo(HaveOccurred()) + + s.TimestampMode = TimestampModeFull + stamp := time.Unix(1234567890, 0).In(loc) + err = s.appendTimestamp(buf, &stamp) + + Expect(err).NotTo(HaveOccurred()) + Expect(buf.String()).To(Equal(expected)) + }, + T.Entry("Coordinated Universal Time", "UTC", "[2009-02-13T23:31:30Z] "), + T.Entry("Korea Standard Time", "Asia/Seoul", "[2009-02-14T08:31:30+09:00] "), + T.Entry("Central European Time", "CET", "[2009-02-14T00:31:30+01:00] "), + T.Entry("West Brasilia Time", "Brazil/West", "[2009-02-13T19:31:30-04:00] "), ) T.DescribeTable("should return error if writing fails", func(mode TimestampMode) { |