]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Add very basic unit tests for dir scan and db
authorDaira Hopwood <daira@jacaranda.org>
Tue, 28 Apr 2015 18:37:08 +0000 (19:37 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 28 Apr 2015 18:37:08 +0000 (19:37 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/frontends/drop_upload.py
src/allmydata/test/test_drop_upload.py

index 8dfc7449cff91a2c98e87e2d447dd2647291ac2d..e5174d043e26197dab098e8dcac1ed150a65794b 100644 (file)
@@ -117,8 +117,6 @@ class DropUploader(service.MultiService):
         if self._db is None:
             return Failure(Exception('ERROR: Unable to load magic folder db.'))
 
-        self._scan(self._local_path)
-
         service.MultiService.startService(self)
         d = self._notifier.startReading()
 
index 163263cd8df534b71efe9f55237f1a0b1202788e..00dabcab7fe387f2ed4f7ef81d755134f054f205 100644 (file)
@@ -220,6 +220,39 @@ class MockTest(DropUploadTestMixin, unittest.TestCase):
 class RealTest(DropUploadTestMixin, unittest.TestCase):
     """This is skipped unless both Twisted and the platform support inotify."""
 
+    def test_db_basic(self):
+        self.basedir = basedir = os.path.join("dropupload", "basic")
+        fileutil.make_dirs(basedir)
+        dbfile = os.path.join(basedir, "dbfile")
+        bdb = self.create(dbfile)
+
+    def test_uploader_startService(self):
+        self.uploader = None
+        self.inotify = None  # use the appropriate inotify for the platform
+        self.basedir = "drop_upload.RealTest.test_uploader_startService"
+        self.set_up_grid()
+        self.client = self.g.clients[0]
+
+        d = self.client.create_dirnode()
+        def _made_upload_dir(n):
+            self.failUnless(IDirectoryNode.providedBy(n))
+            self.upload_dirnode = n
+            self.upload_dircap = n.get_uri()
+            self.uploader = DropUploader(self.client, self.upload_dircap, self.basedir.encode('utf-8'),
+                                         "magicfolderdb.sqlite", inotify=self.inotify)
+            self.uploader.startService()
+            self.failUnlessEqual(self.uploader._db.VERSION, 2)
+        d.addCallback(_made_upload_dir)
+
+        # Prevent unclean reactor errors.
+        def _cleanup(res):
+            d = defer.succeed(None)
+            if self.uploader is not None:
+                d.addCallback(lambda ign: self.uploader.finish(for_tests=True))
+            d.addCallback(lambda ign: res)
+            return d
+        d.addBoth(_cleanup)
+        return d
 
     def test_drop_upload(self):
         # We should always have runtime.platform.supportsINotify, because we're using