| Index: go/src/infra/libs/git/objectID_test.go
|
| diff --git a/go/src/infra/libs/git/objectID_test.go b/go/src/infra/libs/git/objectID_test.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a5d07a6e32ff05e91c947ece78eb549994502e36
|
| --- /dev/null
|
| +++ b/go/src/infra/libs/git/objectID_test.go
|
| @@ -0,0 +1,43 @@
|
| +// 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 (
|
| + "encoding/hex"
|
| + "testing"
|
| +
|
| + . "github.com/smartystreets/goconvey/convey"
|
| +)
|
| +
|
| +func TestMakeObjectID(t *testing.T) {
|
| + t.Parallel()
|
| +
|
| + Convey("ObjectID", t, func() {
|
| + Convey("NoID", func() {
|
| + So(NoID, ShouldResemble, ObjectID{})
|
| + So(NoID.String(), ShouldEqual, "<NoID>")
|
| + })
|
| +
|
| + Convey("MakeObjectID", func() {
|
| + db := "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
|
| + hdb, err := hex.DecodeString(db)
|
| + So(err, ShouldBeNil)
|
| +
|
| + id := MakeObjectID(db)
|
| + So(id.String(), ShouldEqual, db)
|
| + So(id.RawString(), ShouldEqual, string(hdb))
|
| +
|
| + Convey("Panics when given garbage", func() {
|
| + So(func() { MakeObjectID("cats") }, ShouldPanic)
|
| + So(func() { MakeObjectID("deadcatsdeadcatsdeadcatsdeadcatsdeadcats") }, ShouldPanic)
|
| + })
|
| + })
|
| +
|
| + Convey("MakeObjectIDRawErr lets you intercept the error", func() {
|
| + _, err := MakeObjectIDRawErr([]byte("cats"))
|
| + So(err, ShouldNotBeNil)
|
| + })
|
| + })
|
| +}
|
|
|