DEPRECATE Mongo::Mongo in favor of Mongo::Connection
This commit is contained in:
parent
b5d71d9702
commit
94fe53d96b
12
README.rdoc
12
README.rdoc
@ -9,7 +9,7 @@ many more.
|
|||||||
|
|
||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
db = Mongo::Mongo.new('localhost').db('sample-db')
|
db = Connection.new('localhost').db('sample-db')
|
||||||
coll = db.collection('test')
|
coll = db.collection('test')
|
||||||
|
|
||||||
coll.clear
|
coll.clear
|
||||||
@ -80,7 +80,7 @@ Here is some simple example code:
|
|||||||
require 'mongo'
|
require 'mongo'
|
||||||
|
|
||||||
include Mongo
|
include Mongo
|
||||||
db = Mongo::Mongo.new.db('my-db-name')
|
db = Connection.new.db('my-db-name')
|
||||||
things = db.collection('things')
|
things = db.collection('things')
|
||||||
|
|
||||||
things.clear
|
things.clear
|
||||||
@ -147,10 +147,10 @@ generate _id values. If you want to control _id values or even their types,
|
|||||||
using a PK factory lets you do so.
|
using a PK factory lets you do so.
|
||||||
|
|
||||||
You can tell the Ruby Mongo driver how to create primary keys by passing in
|
You can tell the Ruby Mongo driver how to create primary keys by passing in
|
||||||
the :pk option to the Mongo#db method.
|
the :pk option to the Connection#db method.
|
||||||
|
|
||||||
include Mongo
|
include Mongo
|
||||||
db = Mongo::Mongo.new.db('dbname', :pk => MyPKFactory.new)
|
db = Connection.new.db('dbname', :pk => MyPKFactory.new)
|
||||||
|
|
||||||
A primary key factory object must respond to :create_pk, which should take a
|
A primary key factory object must respond to :create_pk, which should take a
|
||||||
hash and return a hash which merges the original hash with any primary key
|
hash and return a hash which merges the original hash with any primary key
|
||||||
@ -205,7 +205,7 @@ completely harmless; strict mode is a programmer convenience only.
|
|||||||
To turn on strict mode, either pass in :strict => true when obtaining a DB
|
To turn on strict mode, either pass in :strict => true when obtaining a DB
|
||||||
object or call the :strict= method:
|
object or call the :strict= method:
|
||||||
|
|
||||||
db = Mongo::Mongo.new.db('dbname', :strict => true)
|
db = Connection.new.db('dbname', :strict => true)
|
||||||
# I'm feeling lax
|
# I'm feeling lax
|
||||||
db.strict = false
|
db.strict = false
|
||||||
# No, I'm not!
|
# No, I'm not!
|
||||||
@ -233,7 +233,7 @@ If you have the source code, you can run the tests.
|
|||||||
$ rake test
|
$ rake test
|
||||||
|
|
||||||
The tests assume that the Mongo database is running on the default port. You
|
The tests assume that the Mongo database is running on the default port. You
|
||||||
can override the default host (localhost) and port (Mongo::DEFAULT_PORT) by
|
can override the default host (localhost) and port (Connection::DEFAULT_PORT) by
|
||||||
using the environment variables MONGO_RUBY_DRIVER_HOST and
|
using the environment variables MONGO_RUBY_DRIVER_HOST and
|
||||||
MONGO_RUBY_DRIVER_PORT.
|
MONGO_RUBY_DRIVER_PORT.
|
||||||
|
|
||||||
|
@ -10,11 +10,11 @@ require 'mongo'
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
host = org_argv[0] || ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = org_argv[0] || ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = org_argv[1] || ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = org_argv[1] || ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
dbnm = org_argv[2] || ENV['MONGO_RUBY_DRIVER_DB'] || 'ruby-mongo-console'
|
dbnm = org_argv[2] || ENV['MONGO_RUBY_DRIVER_DB'] || 'ruby-mongo-console'
|
||||||
|
|
||||||
puts "Connecting to #{host}:#{port} (CONN) on with database #{dbnm} (DB)"
|
puts "Connecting to #{host}:#{port} (CONN) on with database #{dbnm} (DB)"
|
||||||
CONN = Mongo::Mongo.new(host, port)
|
CONN = Connection.new(host, port)
|
||||||
DB = CONN.db(dbnm)
|
DB = CONN.db(dbnm)
|
||||||
|
|
||||||
puts "Starting IRB session..."
|
puts "Starting IRB session..."
|
||||||
|
@ -50,9 +50,9 @@ def benchmark(str, proc, n, db, coll_name, object, setup=nil)
|
|||||||
end
|
end
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
connection = Mongo::Mongo.new(host, port)
|
connection = Connection.new(host, port)
|
||||||
connection.drop_database("benchmark")
|
connection.drop_database("benchmark")
|
||||||
db = connection.db('benchmark')
|
db = connection.db('benchmark')
|
||||||
|
|
||||||
|
@ -5,10 +5,10 @@ require 'pp'
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts "Connecting to #{host}:#{port}"
|
puts "Connecting to #{host}:#{port}"
|
||||||
db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
|
db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||||
coll = db.create_collection('test')
|
coll = db.create_collection('test')
|
||||||
|
|
||||||
# Erase all records from collection, if any
|
# Erase all records from collection, if any
|
||||||
|
@ -4,10 +4,10 @@ $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
|||||||
require 'mongo'
|
require 'mongo'
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts "Connecting to #{host}:#{port}"
|
puts "Connecting to #{host}:#{port}"
|
||||||
db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
|
db = Mongo::Connection.new(host, port).db('ruby-mongo-examples')
|
||||||
coll = db.collection('test')
|
coll = db.collection('test')
|
||||||
coll.clear
|
coll.clear
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@ require 'mongo'
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts ">> Connecting to #{host}:#{port}"
|
puts ">> Connecting to #{host}:#{port}"
|
||||||
DB = Mongo::Mongo.new(host, port).db('ruby-mongo-blog')
|
DB = Connection.new(host, port).db('ruby-mongo-blog')
|
||||||
|
|
||||||
LINE_SIZE = 120
|
LINE_SIZE = 120
|
||||||
puts "=" * LINE_SIZE
|
puts "=" * LINE_SIZE
|
||||||
|
@ -4,10 +4,10 @@ require 'mongo'
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts "Connecting to #{host}:#{port}"
|
puts "Connecting to #{host}:#{port}"
|
||||||
db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
|
db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||||
db.drop_collection('test')
|
db.drop_collection('test')
|
||||||
|
|
||||||
# A capped collection has a max size and optionally a max number of records.
|
# A capped collection has a max size and optionally a max number of records.
|
||||||
|
@ -5,10 +5,10 @@ require 'pp'
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts "Connecting to #{host}:#{port}"
|
puts "Connecting to #{host}:#{port}"
|
||||||
db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
|
db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||||
coll = db.collection('test')
|
coll = db.collection('test')
|
||||||
|
|
||||||
# Erase all records from collection, if any
|
# Erase all records from collection, if any
|
||||||
|
@ -6,10 +6,10 @@ include Mongo
|
|||||||
include GridFS
|
include GridFS
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts "Connecting to #{host}:#{port}"
|
puts "Connecting to #{host}:#{port}"
|
||||||
db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
|
db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||||
|
|
||||||
def dump(db, fname)
|
def dump(db, fname)
|
||||||
GridStore.open(db, fname, 'r') { |f| puts f.read }
|
GridStore.open(db, fname, 'r') { |f| puts f.read }
|
||||||
|
@ -10,10 +10,10 @@ require 'mongo'
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts ">> Connecting to #{host}:#{port}"
|
puts ">> Connecting to #{host}:#{port}"
|
||||||
db = Mongo::Mongo.new(host, port).db('ruby-mongo-index_test')
|
db = Connection.new(host, port).db('ruby-mongo-index_test')
|
||||||
|
|
||||||
puts ">> Dropping collection test"
|
puts ">> Dropping collection test"
|
||||||
begin
|
begin
|
||||||
|
@ -4,10 +4,10 @@ require 'mongo'
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts "Connecting to #{host}:#{port}"
|
puts "Connecting to #{host}:#{port}"
|
||||||
db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
|
db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||||
coll = db.collection('test')
|
coll = db.collection('test')
|
||||||
|
|
||||||
# Erase all records from collection, if any
|
# Erase all records from collection, if any
|
||||||
|
@ -5,10 +5,10 @@ require 'pp'
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts "Connecting to #{host}:#{port}"
|
puts "Connecting to #{host}:#{port}"
|
||||||
db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
|
db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||||
coll = db.collection('test')
|
coll = db.collection('test')
|
||||||
|
|
||||||
# Remove all records, if any
|
# Remove all records, if any
|
||||||
|
@ -4,10 +4,10 @@ require 'mongo'
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts "Connecting to #{host}:#{port}"
|
puts "Connecting to #{host}:#{port}"
|
||||||
db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
|
db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||||
coll = db.collection('test')
|
coll = db.collection('test')
|
||||||
|
|
||||||
# Erase all records from collection, if any
|
# Erase all records from collection, if any
|
||||||
|
@ -4,10 +4,10 @@ require 'mongo'
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts "Connecting to #{host}:#{port}"
|
puts "Connecting to #{host}:#{port}"
|
||||||
db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
|
db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||||
|
|
||||||
db.drop_collection('does-not-exist')
|
db.drop_collection('does-not-exist')
|
||||||
db.create_collection('test')
|
db.create_collection('test')
|
||||||
|
@ -5,10 +5,10 @@ require 'pp'
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
|
|
||||||
puts "Connecting to #{host}:#{port}"
|
puts "Connecting to #{host}:#{port}"
|
||||||
db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
|
db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||||
coll = db.collection('test')
|
coll = db.collection('test')
|
||||||
|
|
||||||
# Remove all records, if any
|
# Remove all records, if any
|
||||||
|
@ -5,7 +5,7 @@ require 'mongo/types/regexp_of_holding'
|
|||||||
require 'mongo/types/undefined'
|
require 'mongo/types/undefined'
|
||||||
|
|
||||||
require 'mongo/errors'
|
require 'mongo/errors'
|
||||||
require 'mongo/mongo'
|
require 'mongo/connection'
|
||||||
require 'mongo/message'
|
require 'mongo/message'
|
||||||
require 'mongo/db'
|
require 'mongo/db'
|
||||||
require 'mongo/cursor'
|
require 'mongo/cursor'
|
||||||
|
@ -18,8 +18,8 @@ require 'mongo/db'
|
|||||||
|
|
||||||
module Mongo
|
module Mongo
|
||||||
|
|
||||||
# Represents a Mongo database server.
|
# A connection to MongoDB.
|
||||||
class Mongo
|
class Connection
|
||||||
|
|
||||||
DEFAULT_PORT = 27017
|
DEFAULT_PORT = 27017
|
||||||
|
|
||||||
@ -50,23 +50,23 @@ module Mongo
|
|||||||
#
|
#
|
||||||
# Since that's so confusing, here are a few examples:
|
# Since that's so confusing, here are a few examples:
|
||||||
#
|
#
|
||||||
# Mongo.new # localhost, DEFAULT_PORT, !slave
|
# Connection.new # localhost, DEFAULT_PORT, !slave
|
||||||
# Mongo.new("localhost") # localhost, DEFAULT_PORT, !slave
|
# Connection.new("localhost") # localhost, DEFAULT_PORT, !slave
|
||||||
# Mongo.new("localhost", 3000) # localhost, 3000, slave not ok
|
# Connection.new("localhost", 3000) # localhost, 3000, slave not ok
|
||||||
# # localhost, 3000, slave ok
|
# # localhost, 3000, slave ok
|
||||||
# Mongo.new("localhost", 3000, :slave_ok => true)
|
# Connection.new("localhost", 3000, :slave_ok => true)
|
||||||
# # localhost, DEFAULT_PORT, auto reconnect
|
# # localhost, DEFAULT_PORT, auto reconnect
|
||||||
# Mongo.new(nil, nil, :auto_reconnect => true)
|
# Connection.new(nil, nil, :auto_reconnect => true)
|
||||||
#
|
#
|
||||||
# # A pair of servers. DB will always talk to the master. On socket
|
# # A pair of servers. DB will always talk to the master. On socket
|
||||||
# # error or "not master" error, we will auto-reconnect to the
|
# # error or "not master" error, we will auto-reconnect to the
|
||||||
# # current master.
|
# # current master.
|
||||||
# Mongo.new({:left => ["db1.example.com", 3000],
|
# Connection.new({:left => ["db1.example.com", 3000],
|
||||||
# :right => "db2.example.com"}, # DEFAULT_PORT
|
# :right => "db2.example.com"}, # DEFAULT_PORT
|
||||||
# nil, :auto_reconnect => true)
|
# nil, :auto_reconnect => true)
|
||||||
#
|
#
|
||||||
# # Here, :right is localhost/DEFAULT_PORT. No auto-reconnect.
|
# # Here, :right is localhost/DEFAULT_PORT. No auto-reconnect.
|
||||||
# Mongo.new({:left => ["db1.example.com", 3000]})
|
# Connection.new({:left => ["db1.example.com", 3000]})
|
||||||
#
|
#
|
||||||
# When a DB object first connects to a pair, it will find the master
|
# When a DB object first connects to a pair, it will find the master
|
||||||
# instance and connect to that one.
|
# instance and connect to that one.
|
||||||
@ -154,6 +154,13 @@ module Mongo
|
|||||||
db.close if db
|
db.close if db
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mongo < Connection
|
||||||
|
def initialize(pair_or_host=nil, port=nil, options={})
|
||||||
|
super(pair_or_host, port, options)
|
||||||
|
|
||||||
|
warn "Mongo::Mongo is deprecated and will be removed - please use Mongo::Connection"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -75,7 +75,7 @@ module Mongo
|
|||||||
#
|
#
|
||||||
# db_name :: The database name
|
# db_name :: The database name
|
||||||
#
|
#
|
||||||
# nodes :: An array of [host, port] pairs. See Mongo#new, which offers
|
# nodes :: An array of [host, port] pairs. See Connection#new, which offers
|
||||||
# a more flexible way of defining nodes.
|
# a more flexible way of defining nodes.
|
||||||
#
|
#
|
||||||
# options :: A hash of options.
|
# options :: A hash of options.
|
||||||
|
@ -19,6 +19,7 @@ PACKAGE_FILES = ['README.rdoc', 'Rakefile', 'mongo-ruby-driver.gemspec',
|
|||||||
'examples/types.rb',
|
'examples/types.rb',
|
||||||
'lib/mongo/admin.rb',
|
'lib/mongo/admin.rb',
|
||||||
'lib/mongo/collection.rb',
|
'lib/mongo/collection.rb',
|
||||||
|
'lib/mongo/connection.rb',
|
||||||
'lib/mongo/cursor.rb',
|
'lib/mongo/cursor.rb',
|
||||||
'lib/mongo/db.rb',
|
'lib/mongo/db.rb',
|
||||||
'lib/mongo/gridfs/chunk.rb',
|
'lib/mongo/gridfs/chunk.rb',
|
||||||
@ -36,7 +37,6 @@ PACKAGE_FILES = ['README.rdoc', 'Rakefile', 'mongo-ruby-driver.gemspec',
|
|||||||
'lib/mongo/message/remove_message.rb',
|
'lib/mongo/message/remove_message.rb',
|
||||||
'lib/mongo/message/update_message.rb',
|
'lib/mongo/message/update_message.rb',
|
||||||
'lib/mongo/message.rb',
|
'lib/mongo/message.rb',
|
||||||
'lib/mongo/mongo.rb',
|
|
||||||
'lib/mongo/query.rb',
|
'lib/mongo/query.rb',
|
||||||
'lib/mongo/types/binary.rb',
|
'lib/mongo/types/binary.rb',
|
||||||
'lib/mongo/types/code.rb',
|
'lib/mongo/types/code.rb',
|
||||||
@ -68,13 +68,13 @@ TEST_FILES = ['test/mongo-qa/_common.rb',
|
|||||||
'test/test_byte_buffer.rb',
|
'test/test_byte_buffer.rb',
|
||||||
'test/test_chunk.rb',
|
'test/test_chunk.rb',
|
||||||
'test/test_collection.rb',
|
'test/test_collection.rb',
|
||||||
|
'test/test_connection.rb',
|
||||||
'test/test_cursor.rb',
|
'test/test_cursor.rb',
|
||||||
'test/test_db.rb',
|
'test/test_db.rb',
|
||||||
'test/test_db_api.rb',
|
'test/test_db_api.rb',
|
||||||
'test/test_db_connection.rb',
|
'test/test_db_connection.rb',
|
||||||
'test/test_grid_store.rb',
|
'test/test_grid_store.rb',
|
||||||
'test/test_message.rb',
|
'test/test_message.rb',
|
||||||
'test/test_mongo.rb',
|
|
||||||
'test/test_objectid.rb',
|
'test/test_objectid.rb',
|
||||||
'test/test_ordered_hash.rb',
|
'test/test_ordered_hash.rb',
|
||||||
'test/test_threading.rb',
|
'test/test_threading.rb',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), '_common.rb')
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
||||||
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
|
|
||||||
db.collection('test').insert({'test' => 1})
|
db.collection('test').insert({'test' => 1})
|
||||||
admin = db.admin
|
admin = db.admin
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), '_common.rb')
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
||||||
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
|
|
||||||
if $DEBUG
|
if $DEBUG
|
||||||
db.drop_collection('capped1')
|
db.drop_collection('capped1')
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), '_common.rb')
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
||||||
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
|
|
||||||
if $DEBUG
|
if $DEBUG
|
||||||
3.times { |i| db.drop_collection("test#{i+1}") }
|
3.times { |i| db.drop_collection("test#{i+1}") }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), '_common.rb')
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
||||||
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
|
|
||||||
if $DEBUG
|
if $DEBUG
|
||||||
3.times { |i| db.drop_collection("dbs_#{i+1}") }
|
3.times { |i| db.drop_collection("dbs_#{i+1}") }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), '_common.rb')
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
||||||
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
|
|
||||||
if $DEBUG
|
if $DEBUG
|
||||||
db.drop_collection('test')
|
db.drop_collection('test')
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), '_common.rb')
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
||||||
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
|
|
||||||
if $DEBUG
|
if $DEBUG
|
||||||
db.drop_collection('c')
|
db.drop_collection('c')
|
||||||
|
@ -5,7 +5,7 @@ require File.join(File.dirname(__FILE__), '_common.rb')
|
|||||||
require 'mongo/gridfs'
|
require 'mongo/gridfs'
|
||||||
include GridFS
|
include GridFS
|
||||||
|
|
||||||
db = Mongo::Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
|
|
||||||
input_file = ARGV[0]
|
input_file = ARGV[0]
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ require File.join(File.dirname(__FILE__), '_common.rb')
|
|||||||
require 'mongo/gridfs'
|
require 'mongo/gridfs'
|
||||||
include GridFS
|
include GridFS
|
||||||
|
|
||||||
db = Mongo::Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
|
|
||||||
input_file = ARGV[0]
|
input_file = ARGV[0]
|
||||||
output_file = ARGV[1]
|
output_file = ARGV[1]
|
||||||
|
@ -4,7 +4,7 @@ require File.join(File.dirname(__FILE__), '_common.rb')
|
|||||||
|
|
||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
db = Mongo::Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
x = db.collection('x')
|
x = db.collection('x')
|
||||||
y = db.collection('y')
|
y = db.collection('y')
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), '_common.rb')
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
||||||
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
|
|
||||||
if $DEBUG
|
if $DEBUG
|
||||||
c = db.collection('remove1')
|
c = db.collection('remove1')
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
LONG_STRING = "lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" * 6
|
LONG_STRING = "lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" * 6
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), '_common.rb')
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
||||||
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
c = db.collection('stress1')
|
c = db.collection('stress1')
|
||||||
|
|
||||||
n1 = 50_000
|
n1 = 50_000
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), '_common.rb')
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
||||||
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
coll = db.collection('part1')
|
coll = db.collection('part1')
|
||||||
|
|
||||||
if $DEBUG
|
if $DEBUG
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), '_common.rb')
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
||||||
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
||||||
foo = db.collection('foo')
|
foo = db.collection('foo')
|
||||||
|
|
||||||
if $DEBUG
|
if $DEBUG
|
||||||
|
@ -7,8 +7,8 @@ class AdminTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
@@db = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
||||||
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')
|
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT).db('ruby-mongo-test')
|
||||||
@@coll = @@db.collection('test')
|
@@coll = @@db.collection('test')
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
@ -8,8 +8,8 @@ class ChunkTest < Test::Unit::TestCase
|
|||||||
include Mongo
|
include Mongo
|
||||||
include GridFS
|
include GridFS
|
||||||
|
|
||||||
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
@@db = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
||||||
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-utils-test')
|
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT).db('ruby-mongo-utils-test')
|
||||||
@@files = @@db.collection('gridfs.files')
|
@@files = @@db.collection('gridfs.files')
|
||||||
@@chunks = @@db.collection('gridfs.chunks')
|
@@chunks = @@db.collection('gridfs.chunks')
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ require 'test/unit'
|
|||||||
class TestCollection < Test::Unit::TestCase
|
class TestCollection < Test::Unit::TestCase
|
||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
@@db = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
||||||
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')
|
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT).db('ruby-mongo-test')
|
||||||
@@test = @@db.collection("test")
|
@@test = @@db.collection("test")
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
@ -3,14 +3,14 @@ require 'mongo'
|
|||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
||||||
# NOTE: assumes Mongo is running
|
# NOTE: assumes Mongo is running
|
||||||
class MongoTest < Test::Unit::TestCase
|
class TestConnection < Test::Unit::TestCase
|
||||||
|
|
||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT
|
@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
@mongo = Mongo.new(@host, @port)
|
@mongo = Connection.new(@host, @port)
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
@ -67,23 +67,47 @@ class MongoTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_pair
|
def test_pair
|
||||||
db = Mongo.new({:left => ['foo', 123]})
|
db = Connection.new({:left => ['foo', 123]})
|
||||||
pair = db.instance_variable_get('@pair')
|
pair = db.instance_variable_get('@pair')
|
||||||
assert_equal 2, pair.length
|
assert_equal 2, pair.length
|
||||||
assert_equal ['foo', 123], pair[0]
|
assert_equal ['foo', 123], pair[0]
|
||||||
assert_equal ['localhost', Mongo::DEFAULT_PORT], pair[1]
|
assert_equal ['localhost', Connection::DEFAULT_PORT], pair[1]
|
||||||
|
|
||||||
db = Mongo.new({:right => 'bar'})
|
db = Connection.new({:right => 'bar'})
|
||||||
pair = db.instance_variable_get('@pair')
|
pair = db.instance_variable_get('@pair')
|
||||||
assert_equal 2, pair.length
|
assert_equal 2, pair.length
|
||||||
assert_equal ['localhost', Mongo::DEFAULT_PORT], pair[0]
|
assert_equal ['localhost', Connection::DEFAULT_PORT], pair[0]
|
||||||
assert_equal ['bar', Mongo::DEFAULT_PORT], pair[1]
|
assert_equal ['bar', Connection::DEFAULT_PORT], pair[1]
|
||||||
|
|
||||||
db = Mongo.new({:right => ['foo', 123], :left => 'bar'})
|
db = Connection.new({:right => ['foo', 123], :left => 'bar'})
|
||||||
pair = db.instance_variable_get('@pair')
|
pair = db.instance_variable_get('@pair')
|
||||||
assert_equal 2, pair.length
|
assert_equal 2, pair.length
|
||||||
assert_equal ['bar', Mongo::DEFAULT_PORT], pair[0]
|
assert_equal ['bar', Connection::DEFAULT_PORT], pair[0]
|
||||||
assert_equal ['foo', 123], pair[1]
|
assert_equal ['foo', 123], pair[1]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Test for deprecated Mongo class
|
||||||
|
class TestMongo < Test::Unit::TestCase
|
||||||
|
|
||||||
|
include Mongo
|
||||||
|
|
||||||
|
def setup
|
||||||
|
@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
|
@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT
|
||||||
|
@mongo = Mongo.new(@host, @port)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_database_info
|
||||||
|
@mongo.drop_database('ruby-mongo-info-test')
|
||||||
|
@mongo.db('ruby-mongo-info-test').collection('info-test').insert('a' => 1)
|
||||||
|
|
||||||
|
info = @mongo.database_info
|
||||||
|
assert_not_nil info
|
||||||
|
assert_kind_of Hash, info
|
||||||
|
assert_not_nil info['ruby-mongo-info-test']
|
||||||
|
assert info['ruby-mongo-info-test'] > 0
|
||||||
|
|
||||||
|
@mongo.drop_database('ruby-mongo-info-test')
|
||||||
|
end
|
||||||
end
|
end
|
@ -7,8 +7,8 @@ class CursorTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
@@db = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
||||||
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')
|
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT).db('ruby-mongo-test')
|
||||||
@@coll = @@db.collection('test')
|
@@coll = @@db.collection('test')
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
@ -16,8 +16,8 @@ class DBTest < Test::Unit::TestCase
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
@@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
@@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
@@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT
|
@@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
@@db = Mongo.new(@@host, @@port).db('ruby-mongo-test')
|
@@db = Connection.new(@@host, @@port).db('ruby-mongo-test')
|
||||||
@@users = @@db.collection('system.users')
|
@@users = @@db.collection('system.users')
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -41,7 +41,7 @@ class DBTest < Test::Unit::TestCase
|
|||||||
rescue => ex
|
rescue => ex
|
||||||
assert_match /NilClass/, ex.to_s
|
assert_match /NilClass/, ex.to_s
|
||||||
ensure
|
ensure
|
||||||
@@db = Mongo.new(@@host, @@port).db('ruby-mongo-test')
|
@@db = Connection.new(@@host, @@port).db('ruby-mongo-test')
|
||||||
@@users = @@db.collection('system.users')
|
@@users = @@db.collection('system.users')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -66,15 +66,15 @@ class DBTest < Test::Unit::TestCase
|
|||||||
def test_pair
|
def test_pair
|
||||||
@@db.close
|
@@db.close
|
||||||
@@users = nil
|
@@users = nil
|
||||||
@@db = Mongo.new({:left => "this-should-fail", :right => [@@host, @@port]}).db('ruby-mongo-test')
|
@@db = Connection.new({:left => "this-should-fail", :right => [@@host, @@port]}).db('ruby-mongo-test')
|
||||||
assert @@db.connected?
|
assert @@db.connected?
|
||||||
ensure
|
ensure
|
||||||
@@db = Mongo.new(@@host, @@port).db('ruby-mongo-test') unless @@db.connected?
|
@@db = Connection.new(@@host, @@port).db('ruby-mongo-test') unless @@db.connected?
|
||||||
@@users = @@db.collection('system.users')
|
@@users = @@db.collection('system.users')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pk_factory
|
def test_pk_factory
|
||||||
db = Mongo.new(@@host, @@port).db('ruby-mongo-test', :pk => TestPKFactory.new)
|
db = Connection.new(@@host, @@port).db('ruby-mongo-test', :pk => TestPKFactory.new)
|
||||||
coll = db.collection('test')
|
coll = db.collection('test')
|
||||||
coll.clear
|
coll.clear
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class DBTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_pk_factory_reset
|
def test_pk_factory_reset
|
||||||
db = Mongo.new(@@host, @@port).db('ruby-mongo-test')
|
db = Connection.new(@@host, @@port).db('ruby-mongo-test')
|
||||||
db.pk_factory = Object.new # first time
|
db.pk_factory = Object.new # first time
|
||||||
begin
|
begin
|
||||||
db.pk_factory = Object.new
|
db.pk_factory = Object.new
|
||||||
@ -121,7 +121,7 @@ class DBTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_auto_connect
|
def test_auto_connect
|
||||||
@@db.close
|
@@db.close
|
||||||
db = Mongo.new(@@host, @@port, :auto_reconnect => true).db('ruby-mongo-test')
|
db = Connection.new(@@host, @@port, :auto_reconnect => true).db('ruby-mongo-test')
|
||||||
assert db.connected?
|
assert db.connected?
|
||||||
assert db.auto_reconnect?
|
assert db.auto_reconnect?
|
||||||
db.close
|
db.close
|
||||||
@ -130,7 +130,7 @@ class DBTest < Test::Unit::TestCase
|
|||||||
db.collection('test').insert('a' => 1)
|
db.collection('test').insert('a' => 1)
|
||||||
assert db.connected?
|
assert db.connected?
|
||||||
ensure
|
ensure
|
||||||
@@db = Mongo.new(@@host, @@port).db('ruby-mongo-test')
|
@@db = Connection.new(@@host, @@port).db('ruby-mongo-test')
|
||||||
@@users = @@db.collection('system.users')
|
@@users = @@db.collection('system.users')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ require 'test/unit'
|
|||||||
class DBAPITest < Test::Unit::TestCase
|
class DBAPITest < Test::Unit::TestCase
|
||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
@@db = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
||||||
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')
|
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT).db('ruby-mongo-test')
|
||||||
@@coll = @@db.collection('test')
|
@@coll = @@db.collection('test')
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
@ -9,8 +9,8 @@ class DBConnectionTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_no_exceptions
|
def test_no_exceptions
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
db = Mongo.new(host, port).db('ruby-mongo-demo')
|
db = Connection.new(host, port).db('ruby-mongo-demo')
|
||||||
coll = db.collection('test')
|
coll = db.collection('test')
|
||||||
coll.clear
|
coll.clear
|
||||||
db.error
|
db.error
|
||||||
|
@ -8,8 +8,8 @@ class GridStoreTest < Test::Unit::TestCase
|
|||||||
include Mongo
|
include Mongo
|
||||||
include GridFS
|
include GridFS
|
||||||
|
|
||||||
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
@@db = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
||||||
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')
|
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT).db('ruby-mongo-test')
|
||||||
@@files = @@db.collection('fs.files')
|
@@files = @@db.collection('fs.files')
|
||||||
@@chunks = @@db.collection('fs.chunks')
|
@@chunks = @@db.collection('fs.chunks')
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ class ObjectIDTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_save_and_restore
|
def test_save_and_restore
|
||||||
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
db = Mongo.new(host, port).db('ruby-mongo-test')
|
db = Connection.new(host, port).db('ruby-mongo-test')
|
||||||
coll = db.collection('test')
|
coll = db.collection('test')
|
||||||
|
|
||||||
coll.clear
|
coll.clear
|
||||||
|
@ -7,8 +7,8 @@ class TestThreading < Test::Unit::TestCase
|
|||||||
include Mongo
|
include Mongo
|
||||||
|
|
||||||
@@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
@@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
@@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT
|
@@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
||||||
@@db = Mongo.new(@@host, @@port).db('ruby-mongo-test')
|
@@db = Connection.new(@@host, @@port).db('ruby-mongo-test')
|
||||||
@@coll = @@db.collection('thread-test-collection')
|
@@coll = @@db.collection('thread-test-collection')
|
||||||
|
|
||||||
def test_threading
|
def test_threading
|
||||||
|
@ -19,8 +19,8 @@ require 'test/unit'
|
|||||||
# TODO these tests should be removed - just testing for the deprecated
|
# TODO these tests should be removed - just testing for the deprecated
|
||||||
# XGen::Mongo::Driver include path
|
# XGen::Mongo::Driver include path
|
||||||
class TestXGen < Test::Unit::TestCase
|
class TestXGen < Test::Unit::TestCase
|
||||||
@@db = XGen::Mongo::Driver::Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
@@db = XGen::Mongo::Driver::Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
||||||
ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT).db('ruby-mongo-test')
|
ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Connection::DEFAULT_PORT).db('ruby-mongo-test')
|
||||||
@@test = @@db.collection('test')
|
@@test = @@db.collection('test')
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -48,8 +48,8 @@ class TestXGenInclude < Test::Unit::TestCase
|
|||||||
include XGen::Mongo::Driver
|
include XGen::Mongo::Driver
|
||||||
include XGen::Mongo
|
include XGen::Mongo
|
||||||
|
|
||||||
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
@@db = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
||||||
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')
|
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT).db('ruby-mongo-test')
|
||||||
@@test = @@db.collection('test')
|
@@test = @@db.collection('test')
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
Loading…
Reference in New Issue
Block a user