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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package memory
import (
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v3/core"
)
type ObjectStorageSuite struct{}
var _ = Suite(&ObjectStorageSuite{})
func (s *ObjectStorageSuite) TestNew(c *C) {
os := NewObjectStorage()
o, err := os.New()
c.Assert(err, IsNil)
c.Assert(o.Size(), Equals, int64(0))
}
func (s *ObjectStorageSuite) TestSet(c *C) {
os := NewObjectStorage()
o, err := os.New()
c.Assert(err, IsNil)
o.SetType(core.CommitObject)
o.SetSize(3)
writer, err := o.Writer()
c.Assert(err, IsNil)
defer func() { c.Assert(writer.Close(), IsNil) }()
writer.Write([]byte("foo"))
h, err := os.Set(o)
c.Assert(h.String(), Equals, "bc9968d75e48de59f0870ffb71f5e160bbbdcf52")
}
func (s *ObjectStorageSuite) TestGet(c *C) {
os := NewObjectStorage()
o, err := os.New()
c.Assert(err, IsNil)
o.SetType(core.CommitObject)
o.SetSize(3)
writer, err := o.Writer()
c.Assert(err, IsNil)
defer func() { c.Assert(writer.Close(), IsNil) }()
writer.Write([]byte("foo"))
h, err := os.Set(o)
c.Assert(err, IsNil)
ro, err := os.Get(h)
c.Assert(err, IsNil)
c.Assert(ro, DeepEquals, o)
}
|