11package git
22
33import (
4+ "fmt"
45 "io/ioutil"
56 "time"
67
@@ -42,7 +43,7 @@ func (s *ObjectsSuite) TestNewCommit(c *C) {
4243
4344 c .
Assert (
commit .
Author .
Email ,
Equals ,
"[email protected] " )
4445 c .Assert (commit .Author .Name , Equals , "Máximo Cuadros" )
45- c .Assert (commit .Author .When .Unix ( ), Equals , int64 ( 1427802434 ) )
46+ c .Assert (commit .Author .When .Format ( time . RFC3339 ), Equals , "2015-03-31T13:47:14+02:00" )
4647 c .
Assert (
commit .
Committer .
Email ,
Equals ,
"[email protected] " )
4748 c .Assert (commit .Message , Equals , "Merge pull request #1 from dripolles/feature\n \n Creating changelog\n " )
4849}
@@ -92,17 +93,22 @@ func (s *ObjectsSuite) TestParseSignature(c *C) {
9293 `Foo Bar <[email protected] > 1257894000 +0100` : {
9394 Name : "Foo Bar" ,
949595- When : time .Unix (1257894000 , 0 ),
96+ When : MustParseTime ("2009-11-11 00:00:00 +0100" ),
97+ },
98+ `Foo Bar <[email protected] > 1257894000 -0700` : {
99+ Name : "Foo Bar" ,
100+ 101+ When : MustParseTime ("2009-11-10 16:00:00 -0700" ),
96102 },
97103 `Foo Bar <> 1257894000 +0100` : {
98104 Name : "Foo Bar" ,
99105 Email : "" ,
100- When : time . Unix ( 1257894000 , 0 ),
106+ When : MustParseTime ( "2009-11-11 00:00:00 +0100" ),
101107 },
102108 ` <> 1257894000` : {
103109 Name : "" ,
104110 Email : "" ,
105- When : time . Unix ( 1257894000 , 0 ),
111+ When : MustParseTime ( "2009-11-10 23:00:00 +0000" ),
106112 },
107113108114 Name : "Foo Bar" ,
@@ -122,11 +128,17 @@ func (s *ObjectsSuite) TestParseSignature(c *C) {
122128 }
123129
124130 for raw , exp := range cases {
131+ fmt .Println ("> testing" , raw )
125132 got := & Signature {}
126133 got .Decode ([]byte (raw ))
127134
128135 c .Assert (got .Name , Equals , exp .Name )
129136 c .Assert (got .Email , Equals , exp .Email )
130- c .Assert (got .When .Unix ( ), Equals , exp .When .Unix ( ))
137+ c .Assert (got .When .Format ( time . RFC3339 ), Equals , exp .When .Format ( time . RFC3339 ))
131138 }
132139}
140+
141+ func MustParseTime (value string ) time.Time {
142+ t , _ := time .Parse ("2006-01-02 15:04:05 -0700" , value )
143+ return t
144+ }
0 commit comments