aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/object_test.go
diff options
context:
space:
mode:
authorArieh Schneier <15041913+AriehSchneier@users.noreply.github.com>2023-05-04 07:33:19 +1000
committerArieh Schneier <15041913+AriehSchneier@users.noreply.github.com>2023-05-04 07:33:19 +1000
commit7d183c99d041ecf5f98d6b4c7eb25449e21a5153 (patch)
tree1ed833d6a1ca7194bbf30ace4afa24a0d24b8f5f /storage/filesystem/object_test.go
parentda73c5f950fb399611e3eb608f6ee99f23eb53b5 (diff)
downloadgo-git-7d183c99d041ecf5f98d6b4c7eb25449e21a5153.tar.gz
storage: filesystem, Populate index before use. Fixes #148
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
Diffstat (limited to 'storage/filesystem/object_test.go')
-rw-r--r--storage/filesystem/object_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/storage/filesystem/object_test.go b/storage/filesystem/object_test.go
index 19a7914..b5f137f 100644
--- a/storage/filesystem/object_test.go
+++ b/storage/filesystem/object_test.go
@@ -406,6 +406,21 @@ func (s *FsSuite) TestHashesWithPrefix(c *C) {
c.Assert(hashes[0].String(), Equals, "f3dfe29d268303fc6e1bbce268605fc99573406e")
}
+func (s *FsSuite) TestHashesWithPrefixFromPackfile(c *C) {
+ // Same setup as TestGetFromPackfile
+ fixtures.Basic().ByTag(".git").Test(c, func(f *fixtures.Fixture) {
+ fs := f.DotGit()
+ o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())
+
+ expected := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
+ // Only pass the first 8 bytes
+ hashes, err := o.HashesWithPrefix(expected[:8])
+ c.Assert(err, IsNil)
+ c.Assert(hashes, HasLen, 1)
+ c.Assert(hashes[0], Equals, expected)
+ })
+}
+
func BenchmarkPackfileIter(b *testing.B) {
defer fixtures.Clean()