mongo 0.17.1 → 0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +69 -47
- data/Rakefile +26 -0
- data/lib/mongo.rb +2 -2
- data/lib/mongo/admin.rb +3 -3
- data/lib/mongo/collection.rb +51 -29
- data/lib/mongo/connection.rb +476 -94
- data/lib/mongo/cursor.rb +19 -17
- data/lib/mongo/db.rb +52 -324
- data/lib/mongo/errors.rb +9 -0
- data/lib/mongo/gridfs/grid_store.rb +1 -1
- data/lib/mongo/util/conversions.rb +4 -36
- data/test/replica/count_test.rb +34 -0
- data/test/replica/insert_test.rb +50 -0
- data/test/replica/pooled_insert_test.rb +54 -0
- data/test/replica/query_test.rb +39 -0
- data/test/test_collection.rb +23 -10
- data/test/test_connection.rb +19 -20
- data/test/test_conversions.rb +2 -2
- data/test/test_cursor.rb +18 -18
- data/test/test_db.rb +26 -35
- data/test/test_db_api.rb +9 -30
- data/test/test_helper.rb +15 -0
- data/test/test_slave_connection.rb +5 -4
- data/test/test_threading.rb +2 -2
- data/test/threading/test_threading_large_pool.rb +90 -0
- data/test/unit/collection_test.rb +13 -15
- data/test/unit/connection_test.rb +122 -0
- data/test/unit/cursor_test.rb +4 -32
- data/test/unit/db_test.rb +4 -32
- metadata +8 -2
data/test/unit/cursor_test.rb
CHANGED
@@ -4,7 +4,8 @@ class TestCursor < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
context "Cursor options" do
|
6
6
|
setup do
|
7
|
-
@
|
7
|
+
@connection = stub(:class => Connection)
|
8
|
+
@db = stub(:name => "testing", :slave_ok? => false, :connection => @connection)
|
8
9
|
@collection = stub(:db => @db, :name => "items")
|
9
10
|
@cursor = Cursor.new(@collection)
|
10
11
|
end
|
@@ -64,39 +65,10 @@ class TestCursor < Test::Unit::TestCase
|
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
67
|
-
context "Query options" do
|
68
|
-
should "test timeout true and slave_ok false" do
|
69
|
-
@db = stub(:slave_ok? => false, :name => "testing")
|
70
|
-
@collection = stub(:db => @db, :name => "items")
|
71
|
-
@cursor = Cursor.new(@collection, :timeout => true)
|
72
|
-
assert_equal 0, @cursor.query_opts
|
73
|
-
end
|
74
|
-
|
75
|
-
should "test timeout false and slave_ok false" do
|
76
|
-
@db = stub(:slave_ok? => false, :name => "testing")
|
77
|
-
@collection = stub(:db => @db, :name => "items")
|
78
|
-
@cursor = Cursor.new(@collection, :timeout => false)
|
79
|
-
assert_equal 16, @cursor.query_opts
|
80
|
-
end
|
81
|
-
|
82
|
-
should "set timeout true and slave_ok true" do
|
83
|
-
@db = stub(:slave_ok? => true, :name => "testing")
|
84
|
-
@collection = stub(:db => @db, :name => "items")
|
85
|
-
@cursor = Cursor.new(@collection, :timeout => true)
|
86
|
-
assert_equal 4, @cursor.query_opts
|
87
|
-
end
|
88
|
-
|
89
|
-
should "set timeout false and slave_ok true" do
|
90
|
-
@db = stub(:slave_ok? => true, :name => "testing")
|
91
|
-
@collection = stub(:db => @db, :name => "items")
|
92
|
-
@cursor = Cursor.new(@collection, :timeout => false)
|
93
|
-
assert_equal 20, @cursor.query_opts
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
68
|
context "Query fields" do
|
98
69
|
setup do
|
99
|
-
@
|
70
|
+
@connection = stub(:class => Collection)
|
71
|
+
@db = stub(:slave_ok? => true, :name => "testing", :connection => @connection)
|
100
72
|
@collection = stub(:db => @db, :name => "items")
|
101
73
|
end
|
102
74
|
|
data/test/unit/db_test.rb
CHANGED
@@ -2,16 +2,6 @@ require 'test/test_helper'
|
|
2
2
|
|
3
3
|
class DBTest < Test::Unit::TestCase
|
4
4
|
|
5
|
-
class MockDB < DB
|
6
|
-
attr_accessor :socket
|
7
|
-
|
8
|
-
def connect_to_master
|
9
|
-
true
|
10
|
-
end
|
11
|
-
|
12
|
-
public :add_message_headers
|
13
|
-
end
|
14
|
-
|
15
5
|
def insert_message(db, documents)
|
16
6
|
documents = [documents] unless documents.is_a?(Array)
|
17
7
|
message = ByteBuffer.new
|
@@ -23,7 +13,8 @@ class DBTest < Test::Unit::TestCase
|
|
23
13
|
|
24
14
|
context "DB commands" do
|
25
15
|
setup do
|
26
|
-
@
|
16
|
+
@conn = stub()
|
17
|
+
@db = DB.new("testing", @conn)
|
27
18
|
@collection = mock()
|
28
19
|
@db.stubs(:system_command_collection).returns(@collection)
|
29
20
|
end
|
@@ -43,7 +34,7 @@ class DBTest < Test::Unit::TestCase
|
|
43
34
|
should "create the proper cursor" do
|
44
35
|
@cursor = mock(:next_object => {"ok" => 1})
|
45
36
|
Cursor.expects(:new).with(@collection, :admin => true,
|
46
|
-
:limit => -1, :selector => {:buildinfo => 1}).returns(@cursor)
|
37
|
+
:limit => -1, :selector => {:buildinfo => 1}, :socket => nil).returns(@cursor)
|
47
38
|
command = {:buildinfo => 1}
|
48
39
|
@db.command(command, true)
|
49
40
|
end
|
@@ -51,32 +42,13 @@ class DBTest < Test::Unit::TestCase
|
|
51
42
|
should "raise an error when the command fails" do
|
52
43
|
@cursor = mock(:next_object => {"ok" => 0})
|
53
44
|
Cursor.expects(:new).with(@collection, :admin => true,
|
54
|
-
:limit => -1, :selector => {:buildinfo => 1}).returns(@cursor)
|
45
|
+
:limit => -1, :selector => {:buildinfo => 1}, :socket => nil).returns(@cursor)
|
55
46
|
assert_raise OperationFailure do
|
56
47
|
command = {:buildinfo => 1}
|
57
48
|
@db.command(command, true, true)
|
58
49
|
end
|
59
50
|
end
|
60
51
|
end
|
61
|
-
|
62
|
-
context "safe messages" do
|
63
|
-
setup do
|
64
|
-
@db = MockDB.new("testing", ['localhost', 27017])
|
65
|
-
@collection = mock()
|
66
|
-
@db.stubs(:system_command_collection).returns(@collection)
|
67
|
-
end
|
68
|
-
|
69
|
-
should "receive getlasterror message" do
|
70
|
-
@socket = mock()
|
71
|
-
@socket.stubs(:close)
|
72
|
-
@socket.expects(:flush)
|
73
|
-
@socket.expects(:print).with { |message| message.include?('getlasterror') }
|
74
|
-
@db.socket = @socket
|
75
|
-
@db.stubs(:receive)
|
76
|
-
message = insert_message(@db, {:a => 1})
|
77
|
-
@db.send_message_with_safe_check(Mongo::Constants::OP_QUERY, message)
|
78
|
-
end
|
79
|
-
end
|
80
52
|
end
|
81
53
|
|
82
54
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.18"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Menard
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-11-
|
13
|
+
date: 2009-11-25 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -97,6 +97,10 @@ specification_version: 3
|
|
97
97
|
summary: Ruby driver for the MongoDB
|
98
98
|
test_files:
|
99
99
|
- test/mongo-qa/_common.rb
|
100
|
+
- test/replica/count_test.rb
|
101
|
+
- test/replica/insert_test.rb
|
102
|
+
- test/replica/pooled_insert_test.rb
|
103
|
+
- test/replica/query_test.rb
|
100
104
|
- test/test_admin.rb
|
101
105
|
- test/test_bson.rb
|
102
106
|
- test/test_byte_buffer.rb
|
@@ -115,6 +119,8 @@ test_files:
|
|
115
119
|
- test/test_round_trip.rb
|
116
120
|
- test/test_slave_connection.rb
|
117
121
|
- test/test_threading.rb
|
122
|
+
- test/threading/test_threading_large_pool.rb
|
118
123
|
- test/unit/collection_test.rb
|
124
|
+
- test/unit/connection_test.rb
|
119
125
|
- test/unit/cursor_test.rb
|
120
126
|
- test/unit/db_test.rb
|