- WVPASSEQ(None, l.exists(struct.pack('18xBB', 10, 0)))
- for i in range(10, 15):
- _create_idx(tmpdir, i)
- # delete the midx ...
- # TODO: why do we need to? git.auto_midx() below doesn't?!
- for fn in os.listdir(tmpdir):
- if fn.endswith(b'.midx'):
- os.unlink(os.path.join(tmpdir, fn))
- # and make a new one
- git.auto_midx(tmpdir)
- # check it still doesn't exist - we haven't refreshed
- WVPASSEQ(None, l.exists(struct.pack('18xBB', 10, 0)))
- # check that we still have the midx open, this really
- # just checks more for the kernel API ('deleted' string)
- for fn in openfiles():
- if not b'midx-' in fn:
- continue
- WVPASSEQ(True, b'deleted' in fn)
- # refresh the PackIdxList
- l.refresh()
- # and check that an object in pack 10 exists now
- WVPASSEQ(True, l.exists(struct.pack('18xBB', 10, 0)))
- for fn in openfiles():
- if not b'midx-' in fn:
- continue
- # check that we don't have it open anymore
- WVPASSEQ(False, b'deleted' in fn)
+ WVPASSEQ(None, l.exists(struct.pack('18xBB', 10, 0)))
+ for i in range(10, 15):
+ _create_idx(tmpdir, i)
+ # delete the midx ...
+ # TODO: why do we need to? git.auto_midx() below doesn't?!
+ for fn in os.listdir(tmpdir):
+ if fn.endswith(b'.midx'):
+ os.unlink(os.path.join(tmpdir, fn))
+ # and make a new one
+ git.auto_midx(tmpdir)
+ # check it still doesn't exist - we haven't refreshed
+ WVPASSEQ(None, l.exists(struct.pack('18xBB', 10, 0)))
+ # check that we still have the midx open, this really
+ # just checks more for the kernel API ('deleted' string)
+ for fn in openfiles():
+ if not b'midx-' in fn:
+ continue
+ WVPASSEQ(True, b'deleted' in fn)
+ # refresh the PackIdxList
+ l.refresh()
+ # and check that an object in pack 10 exists now
+ WVPASSEQ(True, l.exists(struct.pack('18xBB', 10, 0)))
+ for fn in openfiles():
+ if not b'midx-' in fn:
+ continue
+ # check that we don't have it open anymore
+ WVPASSEQ(False, b'deleted' in fn)
+
+def test_config():
+ cfg_file = os.path.join(os.path.dirname(__file__), 'sample.conf')
+ no_such_file = os.path.join(os.path.dirname(__file__), 'nosuch.conf')
+ git_config_get = partial(git.git_config_get, cfg_file=cfg_file)
+ WVPASSEQ(git_config_get(b'bup.foo'), b'bar')
+ WVPASSEQ(git_config_get(b'bup.bup'), b'is great')
+ WVPASSEQ(git_config_get(b'bup.end'), b'end')
+ WVPASSEQ(git_config_get(b'bup.comments'), None)
+ WVPASSEQ(git_config_get(b'bup.;comments'), None)
+ WVPASSEQ(git_config_get(b'bup.and'), None)
+ WVPASSEQ(git_config_get(b'bup.#and'), None)
+
+ WVPASSEQ(git.git_config_get(b'bup.foo', cfg_file=no_such_file), None)
+
+ WVEXCEPT(git.GitError, git_config_get, b'bup.isbad', opttype='bool')
+ WVEXCEPT(git.GitError, git_config_get, b'bup.isbad', opttype='int')
+ WVPASSEQ(git_config_get(b'bup.isbad'), b'ok')
+ WVPASSEQ(True, git_config_get(b'bup.istrue1', opttype='bool'))
+ WVPASSEQ(True, git_config_get(b'bup.istrue2', opttype='bool'))
+ WVPASSEQ(True, git_config_get(b'bup.istrue3', opttype='bool'))
+ WVPASSEQ(False, git_config_get(b'bup.isfalse1', opttype='bool'))
+ WVPASSEQ(False, git_config_get(b'bup.isfalse2', opttype='bool'))
+ WVPASSEQ(None, git_config_get(b'bup.nosuchkey', opttype='bool'))
+ WVPASSEQ(1, git_config_get(b'bup.istrue1', opttype='int'))
+ WVPASSEQ(2, git_config_get(b'bup.istrue2', opttype='int'))
+ WVPASSEQ(0, git_config_get(b'bup.isfalse2', opttype='int'))
+ WVPASSEQ(0x777, git_config_get(b'bup.hex', opttype='int'))