| 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)
|
| + })
|
| + }
|
| +
|
| + })
|
| +}
|
|
|