| 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 "fmt" |
| 9 "testing" |
| 10 |
| 11 . "github.com/smartystreets/goconvey/convey" |
| 12 ) |
| 13 |
| 14 func TestBlobFromRaw(t *testing.T) { |
| 15 t.Parallel() |
| 16 |
| 17 data := "Hello world!" |
| 18 Convey(fmt.Sprintf("Simple Blob(%v) should Parse", data), t, func() { |
| 19 b := NewBlobFromRaw([]byte(data)) |
| 20 So(b, ShouldNotBeNil) |
| 21 |
| 22 hexpect := "6769dd60bdf536a83c9353272157893043e9f7d0" |
| 23 Convey("Its hash should be "+hexpect, func() { |
| 24 So(b.ID().String(), ShouldEqual, hexpect) |
| 25 }) |
| 26 |
| 27 Convey("It should meet some basic criteria", func() { |
| 28 So(b.Type(), ShouldEqual, BlobType) |
| 29 So(b.Complete(), ShouldBeTrue) |
| 30 So(b.String(), ShouldEqual, fmt.Sprintf("Blob(%s, <data
len(%d)>)", hexpect, len(data))) |
| 31 |
| 32 So(b, ShouldImplement, (*fmt.Stringer)(nil)) |
| 33 So(b, ShouldImplement, (*InternableObject)(nil)) |
| 34 }) |
| 35 |
| 36 Convey("Its content is what we started with", func() { |
| 37 So(b.RawString(), ShouldEqual, data) |
| 38 }) |
| 39 |
| 40 }) |
| 41 |
| 42 Convey("Blobs with IDs should also parse", t, func() { |
| 43 hexpect := "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" |
| 44 b := NewBlobFromRawWithID(MakeObjectID(hexpect), []byte("sup")) |
| 45 So(b, ShouldNotBeNil) |
| 46 So(b.RawString(), ShouldEqual, "sup") |
| 47 So(b.ID().String(), ShouldEqual, hexpect) |
| 48 }) |
| 49 } |
| OLD | NEW |