github.com/stffabi/git-lfs@v2.3.5-0.20180214015214-8eeaa8d88902+incompatible/git/odb/pack/object_test.go (about) 1 package pack 2 3 import ( 4 "testing" 5 6 "github.com/git-lfs/git-lfs/errors" 7 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestObjectTypeReturnsObjectType(t *testing.T) { 12 o := &Object{ 13 typ: TypeCommit, 14 } 15 16 assert.Equal(t, TypeCommit, o.Type()) 17 } 18 19 func TestObjectUnpackUnpacksData(t *testing.T) { 20 expected := []byte{0x1, 0x2, 0x3, 0x4} 21 22 o := &Object{ 23 data: &ChainSimple{ 24 X: expected, 25 }, 26 } 27 28 data, err := o.Unpack() 29 30 assert.Equal(t, expected, data) 31 assert.NoError(t, err) 32 } 33 34 func TestObjectUnpackPropogatesErrors(t *testing.T) { 35 expected := errors.New("git/odb/pack: testing") 36 37 o := &Object{ 38 data: &ChainSimple{ 39 Err: expected, 40 }, 41 } 42 43 data, err := o.Unpack() 44 45 assert.Nil(t, data) 46 assert.Equal(t, expected, err) 47 }