Debian Codegraph @

plumbing/format/packfile/common_test.go

raw
1 package packfile
2
3 import (
4 "bytes"
5 "testing"
6
7 "github.com/go-git/go-git/v5/plumbing"
8 "github.com/go-git/go-git/v5/storage/memory"
9
10 . "gopkg.in/check.v1"
11 )
12
13 func Test(t *testing.T) { TestingT(t) }
14
15 type CommonSuite struct{}
16
17 var _ = Suite(&CommonSuite{})
18
19 func (s *CommonSuite) TestEmptyUpdateObjectStorage(c *C) {
20 var buf bytes.Buffer
21 sto := memory.NewStorage()
22
23 err := UpdateObjectStorage(sto, &buf)
24 c.Assert(err, Equals, ErrEmptyPackfile)
25 }
26
27 func newObject(t plumbing.ObjectType, cont []byte) plumbing.EncodedObject {
28 o := plumbing.MemoryObject{}
29 o.SetType(t)
30 o.SetSize(int64(len(cont)))
31 o.Write(cont)
32
33 return &o
34 }
35
36 type piece struct {
37 val string
38 times int
39 }
40
41 func genBytes(elements []piece) []byte {
42 var result []byte
43 for _, e := range elements {
44 for i := 0; i < e.times; i++ {
45 result = append(result, e.val...)
46 }
47 }
48
49 return result
50 }