From eb50b5c433f9c5cf7d88295da78211ae2ab731fa Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Thu, 30 Jan 2020 03:23:02 +0100 Subject: [PATCH] Adds tests for DODB::Index(V)#update(String, V). --- spec/test.cr | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/test.cr b/spec/test.cr index 199aff6..29d02b0 100644 --- a/spec/test.cr +++ b/spec/test.cr @@ -260,6 +260,26 @@ describe "DODB::DataBase" do db_ships_by_name.get?(some_new_ship.name).should eq(some_new_ship) end + + it "properly updates" do + db = DODB::SpecDataBase.new + + db_ships_by_name = db.new_index "name", &.name + + Ship.all_ships.each do |ship| + db << ship + end + + new_kisaragi = Ship.kisaragi.clone.tap do |s| + s.name = "Kisaragi Kai" # Don’t think about it too much. + end + + # We’re changing an indexed value on purpose. + db_ships_by_name.update "Kisaragi", new_kisaragi + + db_ships_by_name.get?("Kisaragi").should be_nil + db_ships_by_name.get?(new_kisaragi.name).should eq new_kisaragi + end end describe "partitions" do