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

Unified 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, 2 months 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/libs/git/user_test.go
diff --git a/go/src/infra/libs/git/user_test.go b/go/src/infra/libs/git/user_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..d2b6e19cc521ed2cf8b4fb2ecc3b2bfc875a39dc
--- /dev/null
+++ b/go/src/infra/libs/git/user_test.go
@@ -0,0 +1,48 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package git
+
+import (
+ "fmt"
+ "testing"
+ "time"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestMakeUserSuccess(t *testing.T) {
+ t.Parallel()
+
+ Convey("MakeUserFromCommitLine", t, func() {
+ line := "author Bob Boberton < bob@chromium.org> 1399330903 -0700"
+ expect := User{
+ Name: " Bob Boberton ",
+ Email: " bob@chromium.org",
+ Time: time.Unix(1399330903, 0).In(time.FixedZone("PST", int((-7 * time.Hour).Seconds()))),
+ }
+
+ Convey(fmt.Sprintf("Parses %#v correctly", line), func() {
+ actual, err := MakeUserFromCommitLine("author", line)
+ So(err, ShouldBeNil)
+ So(actual.RawString(), ShouldEqual, expect.RawString())
+ })
+
+ lines := [][2]string{
+ {"committer", "author Bob Boberton < bob@chromium.org> 1399330903 -0700"},
+ {"author", "author Bob boberton bob@chromium.org> 1399330903 -0700"},
+ {"author", "author < bob@chromium.org> 1399330903 -0700"},
+ {"author", ""},
+ }
+
+ for _, itm := range lines {
+ typ, line := itm[0], itm[1]
+ Convey(fmt.Sprintf("Fails to parse %#v as a %s", line, typ), func() {
+ _, err := MakeUserFromCommitLine(typ, line)
+ So(err, ShouldNotBeNil)
+ })
+ }
+
+ })
+}
« 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