Properly removes test database directories.
This commit is contained in:
parent
8d323c2a8c
commit
bc0017c6b7
@ -16,6 +16,8 @@ describe "DODB::DataBase" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
db.to_a.sort.should eq(Ship.all_ships.sort)
|
db.to_a.sort.should eq(Ship.all_ships.sort)
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "rewrite already stored data" do
|
it "rewrite already stored data" do
|
||||||
@ -28,6 +30,8 @@ describe "DODB::DataBase" do
|
|||||||
db[key] = ship
|
db[key] = ship
|
||||||
|
|
||||||
db[key].should eq(ship)
|
db[key].should eq(ship)
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "properly remove data" do
|
it "properly remove data" do
|
||||||
@ -49,6 +53,8 @@ describe "DODB::DataBase" do
|
|||||||
|
|
||||||
db[i]?.should be_nil
|
db[i]?.should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "preserves data on reopening" do
|
it "preserves data on reopening" do
|
||||||
@ -61,6 +67,9 @@ describe "DODB::DataBase" do
|
|||||||
db2 << Ship.mutsuki
|
db2 << Ship.mutsuki
|
||||||
|
|
||||||
db1.to_a.size.should eq(2)
|
db1.to_a.size.should eq(2)
|
||||||
|
|
||||||
|
db1.rm_storage_dir
|
||||||
|
db2.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "iterates in normal and reversed order" do
|
it "iterates in normal and reversed order" do
|
||||||
@ -81,6 +90,8 @@ describe "DODB::DataBase" do
|
|||||||
|
|
||||||
# Actual reversal is tested here.
|
# Actual reversal is tested here.
|
||||||
db.to_a(reversed: true).should eq db.to_a.reverse
|
db.to_a(reversed: true).should eq db.to_a.reverse
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "respects the provided offsets if any" do
|
it "respects the provided offsets if any" do
|
||||||
@ -97,6 +108,8 @@ describe "DODB::DataBase" do
|
|||||||
db.to_a(offset: 0, limit: 3).should eq [
|
db.to_a(offset: 0, limit: 3).should eq [
|
||||||
Ship.mutsuki, Ship.kisaragi, Ship.yayoi
|
Ship.mutsuki, Ship.kisaragi, Ship.yayoi
|
||||||
]
|
]
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -113,6 +126,8 @@ describe "DODB::DataBase" do
|
|||||||
Ship.all_ships.each_with_index do |ship|
|
Ship.all_ships.each_with_index do |ship|
|
||||||
db_ships_by_name.get?(ship.name).should eq(ship)
|
db_ships_by_name.get?(ship.name).should eq(ship)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raise on index overload" do
|
it "raise on index overload" do
|
||||||
@ -127,6 +142,8 @@ describe "DODB::DataBase" do
|
|||||||
expect_raises(DODB::IndexOverload) do
|
expect_raises(DODB::IndexOverload) do
|
||||||
db << Ship.kisaragi
|
db << Ship.kisaragi
|
||||||
end
|
end
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "properly deindex" do
|
it "properly deindex" do
|
||||||
@ -145,6 +162,8 @@ describe "DODB::DataBase" do
|
|||||||
Ship.all_ships.each do |ship|
|
Ship.all_ships.each do |ship|
|
||||||
db_ships_by_name.get?(ship.name).should be_nil
|
db_ships_by_name.get?(ship.name).should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "properly reindex" do
|
it "properly reindex" do
|
||||||
@ -163,6 +182,8 @@ describe "DODB::DataBase" do
|
|||||||
db[key].should eq(some_new_ship)
|
db[key].should eq(some_new_ship)
|
||||||
|
|
||||||
db_ships_by_name.get?(some_new_ship.name).should eq(some_new_ship)
|
db_ships_by_name.get?(some_new_ship.name).should eq(some_new_ship)
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "properly updates" do
|
it "properly updates" do
|
||||||
@ -183,6 +204,8 @@ describe "DODB::DataBase" do
|
|||||||
|
|
||||||
db_ships_by_name.get?("Kisaragi").should be_nil
|
db_ships_by_name.get?("Kisaragi").should be_nil
|
||||||
db_ships_by_name.get?(new_kisaragi.name).should eq new_kisaragi
|
db_ships_by_name.get?(new_kisaragi.name).should eq new_kisaragi
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -213,6 +236,8 @@ describe "DODB::DataBase" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
db_ships_by_class.get?("does-not-exist").should be_nil
|
db_ships_by_class.get?("does-not-exist").should be_nil
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "removes select elements from partitions" do
|
it "removes select elements from partitions" do
|
||||||
@ -231,6 +256,8 @@ describe "DODB::DataBase" do
|
|||||||
|
|
||||||
partition.any?(&.name.==("Kisaragi")).should be_false
|
partition.any?(&.name.==("Kisaragi")).should be_false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -254,6 +281,8 @@ describe "DODB::DataBase" do
|
|||||||
|
|
||||||
# There shouldn’t be one in our data about WWII Japanese warships…
|
# There shouldn’t be one in our data about WWII Japanese warships…
|
||||||
db_ships_by_tags.get?("starship").should be_nil
|
db_ships_by_tags.get?("starship").should be_nil
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "properly removes tags" do
|
it "properly removes tags" do
|
||||||
@ -278,6 +307,8 @@ describe "DODB::DataBase" do
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
db_ships_by_tags.get("flagship").should eq([] of Ship)
|
db_ships_by_tags.get("flagship").should eq([] of Ship)
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "gets items that have multiple tags" do
|
it "gets items that have multiple tags" do
|
||||||
@ -297,6 +328,8 @@ describe "DODB::DataBase" do
|
|||||||
|
|
||||||
results = db_ships_by_tags.get(["flagship"])
|
results = db_ships_by_tags.get(["flagship"])
|
||||||
results.should eq([Ship.yamato])
|
results.should eq([Ship.yamato])
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -319,6 +352,8 @@ describe "DODB::DataBase" do
|
|||||||
results.should eq(ship)
|
results.should eq(ship)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -340,11 +375,12 @@ describe "DODB::DataBase" do
|
|||||||
db_ships_by_name.get?(ship.name).should eq(ship)
|
db_ships_by_name.get?(ship.name).should eq(ship)
|
||||||
db_ships_by_class.get(ship.klass).should contain(ship)
|
db_ships_by_class.get(ship.klass).should contain(ship)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "migrates properly" do
|
it "migrates properly" do
|
||||||
::FileUtils.rm_rf "test-storage-migration-origin"
|
old_db = DODB::SpecDataBase(PrimitiveShip).new "-migration-origin"
|
||||||
old_db = DODB::DataBase(PrimitiveShip).new "test-storage-migration-origin"
|
|
||||||
|
|
||||||
old_ships_by_name = old_db.new_index "name", &.name
|
old_ships_by_name = old_db.new_index "name", &.name
|
||||||
old_ships_by_class = old_db.new_partition "class", &.class_name
|
old_ships_by_class = old_db.new_partition "class", &.class_name
|
||||||
@ -384,6 +420,9 @@ describe "DODB::DataBase" do
|
|||||||
|
|
||||||
ship.tags.any?(&.==("name ship")).should be_true if ship.name == ship.klass
|
ship.tags.any?(&.==("name ship")).should be_true if ship.name == ship.klass
|
||||||
end
|
end
|
||||||
|
|
||||||
|
old_db.rm_storage_dir
|
||||||
|
new_db.rm_storage_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -410,6 +449,8 @@ describe "DODB::DataBase" do
|
|||||||
dump = db.to_a
|
dump = db.to_a
|
||||||
|
|
||||||
dump.size.should eq fork_count * entries_per_fork
|
dump.size.should eq fork_count * entries_per_fork
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works for updating values" do
|
it "works for updating values" do
|
||||||
@ -448,6 +489,8 @@ describe "DODB::DataBase" do
|
|||||||
entry.tags.should eq ["updated"]
|
entry.tags.should eq ["updated"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does parallel-safe updates" do
|
it "does parallel-safe updates" do
|
||||||
@ -473,6 +516,8 @@ describe "DODB::DataBase" do
|
|||||||
processes.each &.wait
|
processes.each &.wait
|
||||||
|
|
||||||
db_entries_by_name.get("test").klass.should eq((fork_count * entries_per_fork).to_s)
|
db_entries_by_name.get("test").klass.should eq((fork_count * entries_per_fork).to_s)
|
||||||
|
|
||||||
|
db.rm_storage_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user