diff options
author | Santiago M. Mola <santi@mola.io> | 2017-07-24 14:19:21 +0200 |
---|---|---|
committer | Santiago M. Mola <santi@mola.io> | 2017-07-27 14:22:40 +0200 |
commit | ae1c4f3df729c3a7fed4cd5a1f530c95d640497a (patch) | |
tree | a1468ab8a942435435c644abdc9bac3338990bc2 /plumbing/cache/object_test.go | |
parent | b3fc7760ba332306bb1faa64c8a101a2e605077f (diff) | |
download | go-git-ae1c4f3df729c3a7fed4cd5a1f530c95d640497a.tar.gz |
plumbing/cache: change FIFO to LRU cache
Diffstat (limited to 'plumbing/cache/object_test.go')
-rw-r--r-- | plumbing/cache/object_test.go | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/plumbing/cache/object_test.go b/plumbing/cache/object_test.go index 2a55acf..9359455 100644 --- a/plumbing/cache/object_test.go +++ b/plumbing/cache/object_test.go @@ -12,7 +12,7 @@ import ( func Test(t *testing.T) { TestingT(t) } type ObjectSuite struct { - c *ObjectFIFO + c Object aObject plumbing.EncodedObject bObject plumbing.EncodedObject cObject plumbing.EncodedObject @@ -27,32 +27,26 @@ func (s *ObjectSuite) SetUpTest(c *C) { s.cObject = newObject("cccccccccccccccccccccccccccccccccccccccc", 1*Byte) s.dObject = newObject("dddddddddddddddddddddddddddddddddddddddd", 1*Byte) - s.c = NewObjectFIFO(2 * Byte) + s.c = NewObjectLRU(2 * Byte) } -func (s *ObjectSuite) TestAdd_SameObject(c *C) { +func (s *ObjectSuite) TestPutSameObject(c *C) { s.c.Put(s.aObject) - c.Assert(s.c.actualSize, Equals, 1*Byte) s.c.Put(s.aObject) - c.Assert(s.c.actualSize, Equals, 1*Byte) + _, ok := s.c.Get(s.aObject.Hash()) + c.Assert(ok, Equals, true) } -func (s *ObjectSuite) TestAdd_BigObject(c *C) { +func (s *ObjectSuite) TestPutBigObject(c *C) { s.c.Put(s.bObject) - c.Assert(s.c.actualSize, Equals, 0*Byte) - c.Assert(s.c.actualSize, Equals, 0*KiByte) - c.Assert(s.c.actualSize, Equals, 0*MiByte) - c.Assert(s.c.actualSize, Equals, 0*GiByte) - c.Assert(len(s.c.objects), Equals, 0) + _, ok := s.c.Get(s.aObject.Hash()) + c.Assert(ok, Equals, false) } -func (s *ObjectSuite) TestAdd_CacheOverflow(c *C) { +func (s *ObjectSuite) TestPutCacheOverflow(c *C) { s.c.Put(s.aObject) - c.Assert(s.c.actualSize, Equals, 1*Byte) s.c.Put(s.cObject) - c.Assert(len(s.c.objects), Equals, 2) s.c.Put(s.dObject) - c.Assert(len(s.c.objects), Equals, 2) obj, ok := s.c.Get(s.aObject.Hash()) c.Assert(ok, Equals, false) @@ -67,9 +61,7 @@ func (s *ObjectSuite) TestAdd_CacheOverflow(c *C) { func (s *ObjectSuite) TestClear(c *C) { s.c.Put(s.aObject) - c.Assert(s.c.actualSize, Equals, 1*Byte) s.c.Clear() - c.Assert(s.c.actualSize, Equals, 0*Byte) obj, ok := s.c.Get(s.aObject.Hash()) c.Assert(ok, Equals, false) c.Assert(obj, IsNil) |