minor: added a new group test

This commit is contained in:
Kyle Banker 2010-11-09 12:04:47 -05:00
parent 8e79793053
commit 59ba221066
1 changed files with 23 additions and 1 deletions

View File

@ -130,6 +130,11 @@ class TestCollection < Test::Unit::TestCase
end end
end end
def test_safe_responses
response = @@test.insert({:a => 1}, :safe => true)
assert_equal false, response
end
def test_maximum_insert_size def test_maximum_insert_size
docs = [] docs = []
16.times do 16.times do
@ -556,7 +561,7 @@ class TestCollection < Test::Unit::TestCase
end end
context "Grouping" do context "Grouping" do
setup do setup do
@@test.remove @@test.remove
@@test.save("a" => 1) @@test.save("a" => 1)
@@test.save("b" => 1) @@test.save("b" => 1)
@ -576,6 +581,23 @@ class TestCollection < Test::Unit::TestCase
end end
end end
context "Grouping with key" do
setup do
@@test.remove
@@test.save("a" => 1, "pop" => 100)
@@test.save("a" => 1, "pop" => 100)
@@test.save("a" => 2, "pop" => 100)
@@test.save("a" => 2, "pop" => 100)
@initial = {"count" => 0, "foo" => 1}
@reduce_function = "function (obj, prev) { prev.count += obj.pop; }"
end
should "group" do
result = @@test.group([:a], {}, @initial, @reduce_function, nil)
assert result.all? { |r| r['count'] == 200 }
end
end
context "Grouping with a key function" do context "Grouping with a key function" do
setup do setup do
@@test.remove @@test.remove