Fix timezone handling in time tests.

This commit is contained in:
Gustavo Niemeyer 2015-02-24 19:53:31 -03:00
Родитель 50f7813e6b
Коммит d0fefed9b6
2 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -550,7 +550,7 @@ var unmarshalTests = []struct {
map[string]net.IP{"a": net.IPv4(1, 2, 3, 4)}, map[string]net.IP{"a": net.IPv4(1, 2, 3, 4)},
}, },
{ {
"a: 2015-02-24T15:19:39-03:00\n", "a: 2015-02-24T18:19:39Z\n",
map[string]time.Time{"a": time.Unix(1424801979, 0)}, map[string]time.Time{"a": time.Unix(1424801979, 0)},
}, },

Просмотреть файл

@ -10,6 +10,7 @@ import (
. "gopkg.in/check.v1" . "gopkg.in/check.v1"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"net" "net"
"os"
) )
var marshalIntTest = 123 var marshalIntTest = 123
@ -297,7 +298,7 @@ var marshalTests = []struct {
}, },
{ {
map[string]time.Time{"a": time.Unix(1424801979, 0)}, map[string]time.Time{"a": time.Unix(1424801979, 0)},
"a: 2015-02-24T15:19:39-03:00\n", "a: 2015-02-24T18:19:39Z\n",
}, },
// Ensure strings containing ": " are quoted (reported as PR #43, but not reproducible). // Ensure strings containing ": " are quoted (reported as PR #43, but not reproducible).
@ -308,6 +309,8 @@ var marshalTests = []struct {
} }
func (s *S) TestMarshal(c *C) { func (s *S) TestMarshal(c *C) {
defer os.Setenv("TZ", os.Getenv("TZ"))
os.Setenv("TZ", "UTC")
for _, item := range marshalTests { for _, item := range marshalTests {
data, err := yaml.Marshal(item.value) data, err := yaml.Marshal(item.value)
c.Assert(err, IsNil) c.Assert(err, IsNil)