| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package git |
| 6 |
| 7 import ( |
| 8 "fmt" |
| 9 "testing" |
| 10 "time" |
| 11 |
| 12 . "github.com/smartystreets/goconvey/convey" |
| 13 ) |
| 14 |
| 15 func TestMakeUserSuccess(t *testing.T) { |
| 16 t.Parallel() |
| 17 |
| 18 Convey("MakeUserFromCommitLine", t, func() { |
| 19 line := "author Bob Boberton < bob@chromium.org> 1399330903 -0
700" |
| 20 expect := User{ |
| 21 Name: " Bob Boberton ", |
| 22 Email: " bob@chromium.org", |
| 23 Time: time.Unix(1399330903, 0).In(time.FixedZone("PST",
int((-7 * time.Hour).Seconds()))), |
| 24 } |
| 25 |
| 26 Convey(fmt.Sprintf("Parses %#v correctly", line), func() { |
| 27 actual, err := MakeUserFromCommitLine("author", line) |
| 28 So(err, ShouldBeNil) |
| 29 So(actual.RawString(), ShouldEqual, expect.RawString()) |
| 30 }) |
| 31 |
| 32 lines := [][2]string{ |
| 33 {"committer", "author Bob Boberton < bob@chromium.org>
1399330903 -0700"}, |
| 34 {"author", "author Bob boberton bob@chromium.org> 13993
30903 -0700"}, |
| 35 {"author", "author < bob@chromium.org> 1399330903 -0700"
}, |
| 36 {"author", ""}, |
| 37 } |
| 38 |
| 39 for _, itm := range lines { |
| 40 typ, line := itm[0], itm[1] |
| 41 Convey(fmt.Sprintf("Fails to parse %#v as a %s", line, t
yp), func() { |
| 42 _, err := MakeUserFromCommitLine(typ, line) |
| 43 So(err, ShouldNotBeNil) |
| 44 }) |
| 45 } |
| 46 |
| 47 }) |
| 48 } |
| OLD | NEW |