]> arthur.barton.de Git - bup.git/blob - t/tgit.py
Force generated pack indexes to be version 2.
[bup.git] / t / tgit.py
1 import git, time
2 from wvtest import *
3 from helpers import *
4
5
6 @wvtest
7 def testpacks():
8     git.init_repo('pybuptest.tmp')
9     git.verbose = 1
10
11     now = str(time.time())  # hopefully not in any packs yet
12     w = git.PackWriter()
13     w.write('blob', now)
14     w.write('blob', now)
15     w.abort()
16     
17     w = git.PackWriter()
18     hashes = []
19     for i in range(1000):
20         hashes.append(w.write('blob', str(i)))
21     log('\n')
22     nameprefix = w.close()
23     print repr(nameprefix)
24     WVPASS(os.path.exists(nameprefix + '.pack'))
25     WVPASS(os.path.exists(nameprefix + '.idx'))
26
27     r = git.PackIndex(nameprefix + '.idx')
28     print repr(r.fanout)
29
30     for i in range(1000):
31         WVPASS(r.find_offset(hashes[i]) > 0)
32     WVPASS(r.exists(hashes[99]))
33     WVFAIL(r.exists('\0'*20))
34
35     WVFAIL(r.find_offset('\0'*20))
36
37     r = git.MultiPackIndex('pybuptest.tmp/objects/pack')
38     WVPASS(r.exists(hashes[5]))
39     WVPASS(r.exists(hashes[6]))
40     WVFAIL(r.exists('\0'*20))