]> arthur.barton.de Git - bup.git/blobdiff - t/tclient.py
client.py: raising a particular rare exception caused a syntax error.
[bup.git] / t / tclient.py
index 6e7dd9a45a3fa2639eb922b7386591500d09b367..d6f236a6d01b4e049e7a5d05532d2bc6f3d73f72 100644 (file)
@@ -1,4 +1,5 @@
-import os, time, random
+import sys, os, time, random, subprocess
+sys.path.append('../lib')
 from bup import client, git, hashsplit
 from wvtest import *
 
@@ -8,19 +9,19 @@ def randbytes(sz):
         s += chr(random.randrange(0,256))
     return s
 
+s1 = randbytes(10000)
+s2 = randbytes(10000)
+    
 @wvtest
 def test_server_split_with_indexes():
-    os.environ['BUP_MAIN_EXE'] = './bup'
+    os.environ['BUP_MAIN_EXE'] = '../bup'
     os.environ['BUP_DIR'] = bupdir = 'buptest_tclient.tmp'
-    git.init_repo()
-    git.check_repo_or_die()
+    subprocess.call(['rm', '-rf', bupdir])
+    git.init_repo(bupdir)
     lw = git.PackWriter()
     c = client.Client(bupdir, create=True)
     rw = c.new_packwriter()
 
-    s1 = randbytes(10000)
-    s2 = randbytes(10000)
-    
     lw.new_blob(s1)
     lw.close()
 
@@ -28,3 +29,26 @@ def test_server_split_with_indexes():
     rw.breakpoint()
     rw.new_blob(s1)
     
+
+@wvtest
+def test_midx_refreshing():
+    os.environ['BUP_MAIN_EXE'] = bupmain = '../bup'
+    os.environ['BUP_DIR'] = bupdir = 'buptest_tmidx.tmp'
+    subprocess.call(['rm', '-rf', bupdir])
+    git.init_repo(bupdir)
+    lw = git.PackWriter()
+    lw.new_blob(s1)
+    lw.breakpoint()
+    lw.new_blob(s2)
+    del lw
+    pi = git.PackIdxList(bupdir + '/objects/pack')
+    WVPASSEQ(len(pi.packs), 2)
+    pi.refresh()
+    WVPASSEQ(len(pi.packs), 2)
+    subprocess.call([bupmain, 'midx', '-f'])
+    pi.refresh()
+    WVPASSEQ(len(pi.packs), 1)
+    pi.refresh(skip_midx=True)
+    WVPASSEQ(len(pi.packs), 2)
+    pi.refresh(skip_midx=False)
+    WVPASSEQ(len(pi.packs), 1)