Debian Codegraph @

pack/object_test.go

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