ソースを参照

Fix timezone handling in time tests.

Gustavo Niemeyer 11 年 前
コミット
d0fefed9b6
2 ファイル変更5 行追加2 行削除
  1. 1 1
      decode_test.go
  2. 4 1
      encode_test.go

+ 1 - 1
decode_test.go

@@ -550,7 +550,7 @@ var unmarshalTests = []struct {
 		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)},
 	},
 

+ 4 - 1
encode_test.go

@@ -10,6 +10,7 @@ import (
 	. "gopkg.in/check.v1"
 	"gopkg.in/yaml.v2"
 	"net"
+	"os"
 )
 
 var marshalIntTest = 123
@@ -297,7 +298,7 @@ var marshalTests = []struct {
 	},
 	{
 		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).
@@ -308,6 +309,8 @@ var marshalTests = []struct {
 }
 
 func (s *S) TestMarshal(c *C) {
+	defer os.Setenv("TZ", os.Getenv("TZ"))
+	os.Setenv("TZ", "UTC")
 	for _, item := range marshalTests {
 		data, err := yaml.Marshal(item.value)
 		c.Assert(err, IsNil)