Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(960)

Side by Side Diff: go/src/infra/libs/git/blob_test.go

Issue 662113003: Drover's back, baby! (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git/+/master
Patch Set: more tests and refactors Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « go/src/infra/libs/git/blob.go ('k') | go/src/infra/libs/git/child.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « go/src/infra/libs/git/blob.go ('k') | go/src/infra/libs/git/child.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698