| Index: go/src/infra/libs/git/blob_test.go
|
| diff --git a/go/src/infra/libs/git/blob_test.go b/go/src/infra/libs/git/blob_test.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d5cc496c16beeeee3f0f0983d3dd81a64cefab87
|
| --- /dev/null
|
| +++ b/go/src/infra/libs/git/blob_test.go
|
| @@ -0,0 +1,49 @@
|
| +// 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"
|
| +
|
| + . "github.com/smartystreets/goconvey/convey"
|
| +)
|
| +
|
| +func TestBlobFromRaw(t *testing.T) {
|
| + t.Parallel()
|
| +
|
| + data := "Hello world!"
|
| + Convey(fmt.Sprintf("Simple Blob(%v) should Parse", data), t, func() {
|
| + b := NewBlobFromRaw([]byte(data))
|
| + So(b, ShouldNotBeNil)
|
| +
|
| + hexpect := "6769dd60bdf536a83c9353272157893043e9f7d0"
|
| + Convey("Its hash should be "+hexpect, func() {
|
| + So(b.ID().String(), ShouldEqual, hexpect)
|
| + })
|
| +
|
| + Convey("It should meet some basic criteria", func() {
|
| + So(b.Type(), ShouldEqual, BlobType)
|
| + So(b.Complete(), ShouldBeTrue)
|
| + So(b.String(), ShouldEqual, fmt.Sprintf("Blob(%s, <data len(%d)>)", hexpect, len(data)))
|
| +
|
| + So(b, ShouldImplement, (*fmt.Stringer)(nil))
|
| + So(b, ShouldImplement, (*InternableObject)(nil))
|
| + })
|
| +
|
| + Convey("Its content is what we started with", func() {
|
| + So(b.RawString(), ShouldEqual, data)
|
| + })
|
| +
|
| + })
|
| +
|
| + Convey("Blobs with IDs should also parse", t, func() {
|
| + hexpect := "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
|
| + b := NewBlobFromRawWithID(MakeObjectID(hexpect), []byte("sup"))
|
| + So(b, ShouldNotBeNil)
|
| + So(b.RawString(), ShouldEqual, "sup")
|
| + So(b.ID().String(), ShouldEqual, hexpect)
|
| + })
|
| +}
|
|
|