From 069d047d3dcb0eefe59babbd295cfee922aa1476 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 17 Jan 2011 03:07:15 +0000 Subject: test_tdb: fix and expand the repack test We can't repack an in-memory DB, only files --- test/test_tdb.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'test') 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 -- cgit v1.2.3-24-ge0c7