aboutsummaryrefslogtreecommitdiffstats
path: root/objects_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2015-11-23 18:43:22 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2015-11-23 18:43:22 +0100
commit5c8fff7e9e614d9f463d964699539fe71509ba39 (patch)
tree33b5e734d8c38cb93429d3328a07e0280b5b4f8b /objects_test.go
parentcaab43e7f4ee10a15b2af826485b688473b34356 (diff)
parent4f537be5c121129961ddaf74af004a9c2c00d973 (diff)
downloadgo-git-5c8fff7e9e614d9f463d964699539fe71509ba39.tar.gz
Merge pull request #6 from klaidliadon/v2.0.0
Timezone fixes
Diffstat (limited to 'objects_test.go')
-rw-r--r--objects_test.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/objects_test.go b/objects_test.go
index 9bebe26..a51f372 100644
--- a/objects_test.go
+++ b/objects_test.go
@@ -1,6 +1,7 @@
package git
import (
+ "fmt"
"io/ioutil"
"time"
@@ -42,7 +43,7 @@ func (s *ObjectsSuite) TestNewCommit(c *C) {
c.Assert(commit.Author.Email, Equals, "mcuadros@gmail.com")
c.Assert(commit.Author.Name, Equals, "Máximo Cuadros")
- c.Assert(commit.Author.When.Unix(), Equals, int64(1427802434))
+ c.Assert(commit.Author.When.Format(time.RFC3339), Equals, "2015-03-31T13:47:14+02:00")
c.Assert(commit.Committer.Email, Equals, "mcuadros@gmail.com")
c.Assert(commit.Message, Equals, "Merge pull request #1 from dripolles/feature\n\nCreating changelog\n")
}
@@ -92,17 +93,22 @@ func (s *ObjectsSuite) TestParseSignature(c *C) {
`Foo Bar <foo@bar.com> 1257894000 +0100`: {
Name: "Foo Bar",
Email: "foo@bar.com",
- When: time.Unix(1257894000, 0),
+ When: MustParseTime("2009-11-11 00:00:00 +0100"),
+ },
+ `Foo Bar <foo@bar.com> 1257894000 -0700`: {
+ Name: "Foo Bar",
+ Email: "foo@bar.com",
+ When: MustParseTime("2009-11-10 16:00:00 -0700"),
},
`Foo Bar <> 1257894000 +0100`: {
Name: "Foo Bar",
Email: "",
- When: time.Unix(1257894000, 0),
+ When: MustParseTime("2009-11-11 00:00:00 +0100"),
},
` <> 1257894000`: {
Name: "",
Email: "",
- When: time.Unix(1257894000, 0),
+ When: MustParseTime("2009-11-10 23:00:00 +0000"),
},
`Foo Bar <foo@bar.com>`: {
Name: "Foo Bar",
@@ -122,11 +128,17 @@ func (s *ObjectsSuite) TestParseSignature(c *C) {
}
for raw, exp := range cases {
+ fmt.Println("> testing", raw)
got := &Signature{}
got.Decode([]byte(raw))
c.Assert(got.Name, Equals, exp.Name)
c.Assert(got.Email, Equals, exp.Email)
- c.Assert(got.When.Unix(), Equals, exp.When.Unix())
+ c.Assert(got.When.Format(time.RFC3339), Equals, exp.When.Format(time.RFC3339))
}
}
+
+func MustParseTime(value string) time.Time {
+ t, _ := time.Parse("2006-01-02 15:04:05 -0700", value)
+ return t
+}