]> arthur.barton.de Git - bup.git/blob - t/tgit.py
git.PackIndex: a class for quickly searching a git packfile index.
[bup.git] / t / tgit.py
1 import git
2 from wvtest import *
3
4
5 @wvtest
6 def testpacks():
7     w = git.PackWriter()
8     hashes = []
9     for i in range(1000):
10         hashes.append(w.easy_write('blob', str(i)))
11     nameprefix = w.close()
12     print repr(nameprefix)
13     WVPASS(os.path.exists(nameprefix + '.pack'))
14     WVPASS(os.path.exists(nameprefix + '.idx'))
15
16     r = git.PackIndex(nameprefix + '.idx')
17     print repr(r.fanout)
18
19     for i in range(1000):
20         WVPASS(r.find_offset(hashes[i]) > 0)
21     WVPASS(r.exists(hashes[99]))
22     WVFAIL(r.exists('\0'*20))
23
24     WVFAIL(r.find_offset('\0'*20))
25
26     r = git.MultiPackIndex('.git/objects/pack')
27     WVPASS(r.exists(hashes[5]))
28     WVPASS(r.exists(hashes[6]))
29     WVFAIL(r.exists('\0'*20))