aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile/object_pack_test.go
blob: dc1a285a7a07be2ad604b68a1113cfcebbfe7c18 (plain) (blame)
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
package packfile

import (
	"io"

	"github.com/go-git/go-git/v5/plumbing"

	. "gopkg.in/check.v1"
)

type ObjectToPackSuite struct{}

var _ = Suite(&ObjectToPackSuite{})

func (s *ObjectToPackSuite) TestObjectToPack(c *C) {
	obj := &dummyObject{}
	otp := newObjectToPack(obj)
	c.Assert(obj, Equals, otp.Object)
	c.Assert(obj, Equals, otp.Original)
	c.Assert(otp.Base, IsNil)
	c.Assert(otp.IsDelta(), Equals, false)

	original := &dummyObject{}
	delta := &dummyObject{}
	deltaToPack := newDeltaObjectToPack(otp, original, delta)
	c.Assert(obj, Equals, deltaToPack.Object)
	c.Assert(original, Equals, deltaToPack.Original)
	c.Assert(otp, Equals, deltaToPack.Base)
	c.Assert(deltaToPack.IsDelta(), Equals, true)
}

type dummyObject struct{}

func (*dummyObject) Hash() plumbing.Hash             { return plumbing.ZeroHash }
func (*dummyObject) Type() plumbing.ObjectType       { return plumbing.InvalidObject }
func (*dummyObject) SetType(plumbing.ObjectType)     {}
func (*dummyObject) Size() int64                     { return 0 }
func (*dummyObject) SetSize(s int64)                 {}
func (*dummyObject) Reader() (io.ReadCloser, error)  { return nil, nil }
func (*dummyObject) Writer() (io.WriteCloser, error) { return nil, nil }