1package git23import (4 "bytes"5 "context"6 "testing"78 "github.com/stretchr/testify/assert"9)1011func TestBlob(t *testing.T) {12 ctx := context.Background()13 expOutput := `This is a sample project students can use during Matthew's Git class.1415Here is an addition by me1617We can have a bit of fun with this repo, knowing that we can always reset it to a known good state. We can apply labels, and branch, then add new code and merge it in to the master branch.1819As a quick reminder, this came from one of three locations in either SSH, Git, or HTTPS format:2021* git@github.com:matthewmccullough/hellogitworld.git22* git://github.com/matthewmccullough/hellogitworld.git23* https://matthewmccullough@github.com/matthewmccullough/hellogitworld.git2425We can, as an example effort, even modify this README and change it as if it were source code for the purposes of the class.2627This demo also includes an image with changes on a branch for examination of image diff on GitHub.28`2930 blob := &Blob{31 TreeEntry: &TreeEntry{32 mode: EntryBlob,33 typ: ObjectBlob,34 id: testrepoMarks[39], // Blob ID of "README.txt" file35 parent: &Tree{36 repo: testrepo,37 },38 },39 }4041 t.Run("get data all at once", func(t *testing.T) {42 p, err := blob.Bytes(ctx)43 assert.Nil(t, err)44 assert.Equal(t, expOutput, string(p))45 })4647 t.Run("get data with pipe", func(t *testing.T) {48 stdout := new(bytes.Buffer)49 err := blob.Pipe(ctx, stdout)50 assert.Nil(t, err)51 assert.Equal(t, expOutput, stdout.String())52 })53}