Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: go/src/infra/libs/git/user_test.go

Issue 662113003: Drover's back, baby! (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git/+/master
Patch Set: more tests and refactors Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « go/src/infra/libs/git/user.go ('k') | go/src/infra/libs/gitiles/gitiles.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « go/src/infra/libs/git/user.go ('k') | go/src/infra/libs/gitiles/gitiles.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698