Stats tests
This commit is contained in:
parent
418880baa1
commit
09ee9704e4
|
@ -1,17 +1,16 @@
|
|||
require 'fileutils'
|
||||
require 'test_helper'
|
||||
|
||||
class DbTest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
FileUtils::mkdir File.join(File.dirname(__FILE__), 'tmp')
|
||||
mkdir File.join(File.dirname(__FILE__), 'tmp')
|
||||
@db = Bdb::Db.new
|
||||
@db.open(nil, File.join(File.dirname(__FILE__), 'tmp', 'test.db'), nil, Bdb::Db::BTREE, Bdb::DB_CREATE, 0)
|
||||
end
|
||||
|
||||
def teardown
|
||||
assert(@db.close(0)) if @db
|
||||
FileUtils::rm_rf File.join('test', 'tmp')
|
||||
rm_rf File.join(File.dirname(__FILE__), 'tmp')
|
||||
end
|
||||
|
||||
def test_put_and_get
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DbTest < Test::Unit::TestCase
|
||||
class DbStat < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
mkdir File.join(File.dirname(__FILE__), 'tmp')
|
||||
end
|
||||
|
||||
def teardown
|
||||
rm_rf File.join(File.dirname(__FILE__), 'tmp')
|
||||
end
|
||||
|
||||
# rb_define_method(cDbStat,"[]",stat_aref,1);
|
||||
def test_stat
|
||||
|
||||
@db = Bdb::Db.new
|
||||
@db.open(nil, File.join(File.dirname(__FILE__), 'tmp', 'test.db'), nil, Bdb::Db::BTREE, Bdb::DB_CREATE, 0)
|
||||
@db.put(nil, 'key', 'data', 0)
|
||||
stats = @db.stat(nil, 0)
|
||||
assert_equal 1, stats['bt_nkeys']
|
||||
@db.close(0)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require "test/unit"
|
||||
require 'fileutils'
|
||||
require "bdb"
|
||||
|
||||
class Test::Unit::TestCase
|
||||
|
||||
include FileUtils
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue