From d5bed6e43e64aa021cd084abcc632ecb35c57cc3 Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Mon, 18 May 2009 09:59:10 -0400 Subject: [PATCH] test save --- tests/test_db_api.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_db_api.rb b/tests/test_db_api.rb index 07a7d20..3507401 100644 --- a/tests/test_db_api.rb +++ b/tests/test_db_api.rb @@ -561,6 +561,30 @@ class DBAPITest < Test::Unit::TestCase assert_equal nil, @@db.dereference(DBRef.new("test", nil)) end + def test_save + @@coll.clear + + a = {"hello" => "world"} + + @@coll.save(a) + assert_equal 1, @@coll.count + + @@coll.save(@@coll.find_first) + assert_equal 1, @@coll.count + + assert_equal "world", @@coll.find_first()["hello"] + + doc = @@coll.find_first + doc["hello"] = "mike" + @@coll.save(doc) + assert_equal 1, @@coll.count + + assert_equal "mike", @@coll.find_first()["hello"] + + @@coll.save(a) + assert_equal 2, @@coll.count + end + # TODO this test fails with error message "Undefed Before end of object" # That is a database error. The undefined type may go away.