From 544a044105dd7f8fdff4642d54877ae67959f741 Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Mon, 2 Mar 2009 10:49:27 -0500 Subject: [PATCH] tests that already pass --- tests/test_admin.rb | 7 +++++++ tests/test_cursor.rb | 11 +++++++++++ tests/test_db_api.rb | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/tests/test_admin.rb b/tests/test_admin.rb index 9da9fa8..f512557 100644 --- a/tests/test_admin.rb +++ b/tests/test_admin.rb @@ -33,6 +33,13 @@ class AdminTest < Test::Unit::TestCase assert_equal :slow_only, @admin.profiling_level @admin.profiling_level = :off assert_equal :off, @admin.profiling_level + @admin.profiling_level = :all + assert_equal :all, @admin.profiling_level + begin + @admin.profiling_level = :medium + fail "shouldn't be able to do this" + rescue + end end def test_profiling_info diff --git a/tests/test_cursor.rb b/tests/test_cursor.rb index 23b52f7..c2468de 100644 --- a/tests/test_cursor.rb +++ b/tests/test_cursor.rb @@ -40,6 +40,17 @@ class CursorTest < Test::Unit::TestCase end end + def test_refill_via_get_more + 1000.times { |i| + @@coll.insert('a' => i) + } + count = 0 + @@coll.find.each { |obj| + count += obj['a'] + } + assert_equal 499501, count + end + def test_close_after_query_sent begin cursor = @@coll.find('a' => 1) diff --git a/tests/test_db_api.rb b/tests/test_db_api.rb index 0231b45..40ff134 100644 --- a/tests/test_db_api.rb +++ b/tests/test_db_api.rb @@ -233,6 +233,12 @@ class DBAPITest < Test::Unit::TestCase assert !@@db.collection_names.include?(@@coll_full_name) end + def test_other_drop + assert @@db.collection_names.include?(@@coll_full_name) + @@coll.drop + assert !@@db.collection_names.include?(@@coll_full_name) + end + def test_collection_names names = @@db.collection_names assert names.length >= 1 @@ -277,6 +283,7 @@ class DBAPITest < Test::Unit::TestCase def test_index_information name = @@db.create_index(@@coll.name, 'a') list = @@db.index_information(@@coll.name) + assert_equal @@coll.index_information, list assert_equal 1, list.length info = list[0] @@ -368,6 +375,37 @@ class DBAPITest < Test::Unit::TestCase @@db.strict = false @@db.drop_collection('foobar') end + + # Now we're not in strict mode - should succeed + @@db.create_collection('foobar') + @@db.create_collection('foobar') + @@db.drop_collection('foobar') + end + + def test_replace + assert_equal @@coll.count, 1 + assert_equal @@coll.find_first["a"], 1 + + @@coll.replace({"a" => 1}, {"a" => 2}) + assert_equal @@coll.count, 1 + assert_equal @@coll.find_first["a"], 2 + + @@coll.replace({"b" => 1}, {"a" => 3}) + assert_equal @@coll.count, 1 + assert_equal @@coll.find_first["a"], 2 + end + + def test_repsert + assert_equal @@coll.count, 1 + assert_equal @@coll.find_first["a"], 1 + + @@coll.repsert({"a" => 1}, {"a" => 2}) + assert_equal @@coll.count, 1 + assert_equal @@coll.find_first["a"], 2 + + @@coll.repsert({"b" => 1}, {"a" => 3}) + assert_equal @@coll.count, 2 + assert @@coll.find_first({"a" => 3}) end def test_to_a