summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2011-01-17 03:07:15 +0000
committerEric Wong <normalperson@yhbt.net>2011-01-17 08:16:51 +0000
commit069d047d3dcb0eefe59babbd295cfee922aa1476 (patch)
tree446a6b24d2db2fc06763bb75ce9e681ebc627dff
parent1e47ddc03a3f78fc5a74eb8ba7cfa2c3d2ce5399 (diff)
We can't repack an in-memory DB, only files
-rw-r--r--test/test_tdb.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/test_tdb.rb b/test/test_tdb.rb
index 64f34c0..d7a6a8a 100644
--- a/test/test_tdb.rb
+++ b/test/test_tdb.rb
@@ -275,10 +275,20 @@ class TestTdb < Test::Unit::TestCase
     assert ! @tdb.include?("hello")
   end
 
-  def test_repack
-    @tdb = TDB.new(nil)
+  def test_repack_file
+    assert_nothing_raised do
+      @tmp = Tempfile.new('tdb')
+      File.unlink(@tmp.path)
+    end
+    @tdb = TDB.new(@tmp.path)
     @tdb["hello"] = "world"
     assert_equal @tdb, @tdb.repack
     assert_equal "world", @tdb["hello"]
   end if TDB.method_defined?(:repack)
+
+  def test_repack_mem
+    @tdb = TDB.new(nil)
+    @tdb["hello"] = "world"
+    assert_raises(TDB::ERR::EINVAL) { @tdb.repack }
+  end if TDB.method_defined?(:repack)
 end