| 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 "encoding/hex" |
| 9 "testing" |
| 10 |
| 11 . "github.com/smartystreets/goconvey/convey" |
| 12 ) |
| 13 |
| 14 func TestMakeObjectID(t *testing.T) { |
| 15 t.Parallel() |
| 16 |
| 17 Convey("ObjectID", t, func() { |
| 18 Convey("NoID", func() { |
| 19 So(NoID, ShouldResemble, ObjectID{}) |
| 20 So(NoID.String(), ShouldEqual, "<NoID>") |
| 21 }) |
| 22 |
| 23 Convey("MakeObjectID", func() { |
| 24 db := "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" |
| 25 hdb, err := hex.DecodeString(db) |
| 26 So(err, ShouldBeNil) |
| 27 |
| 28 id := MakeObjectID(db) |
| 29 So(id.String(), ShouldEqual, db) |
| 30 So(id.RawString(), ShouldEqual, string(hdb)) |
| 31 |
| 32 Convey("Panics when given garbage", func() { |
| 33 So(func() { MakeObjectID("cats") }, ShouldPanic) |
| 34 So(func() { MakeObjectID("deadcatsdeadcatsdeadca
tsdeadcatsdeadcats") }, ShouldPanic) |
| 35 }) |
| 36 }) |
| 37 |
| 38 Convey("MakeObjectIDRawErr lets you intercept the error", func()
{ |
| 39 _, err := MakeObjectIDRawErr([]byte("cats")) |
| 40 So(err, ShouldNotBeNil) |
| 41 }) |
| 42 }) |
| 43 } |
| OLD | NEW |