File: object_test.go

package info (click to toggle)
golang-github-git-lfs-gitobj 2.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 432 kB
  • sloc: makefile: 2; sh: 1
file content (46 lines) | stat: -rw-r--r-- 702 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package pack

import (
	"fmt"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestObjectTypeReturnsObjectType(t *testing.T) {
	o := &Object{
		typ: TypeCommit,
	}

	assert.Equal(t, TypeCommit, o.Type())
}

func TestObjectUnpackUnpacksData(t *testing.T) {
	expected := []byte{0x1, 0x2, 0x3, 0x4}

	o := &Object{
		data: &ChainSimple{
			X: expected,
		},
	}

	data, err := o.Unpack()

	assert.Equal(t, expected, data)
	assert.NoError(t, err)
}

func TestObjectUnpackPropogatesErrors(t *testing.T) {
	expected := fmt.Errorf("gitobj/pack: testing")

	o := &Object{
		data: &ChainSimple{
			Err: expected,
		},
	}

	data, err := o.Unpack()

	assert.Nil(t, data)
	assert.Equal(t, expected, err)
}