-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
272 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
# encoding:utf-8 | ||
|
||
require 'test/test_helper' | ||
|
||
class BinaryTest < Test::Unit::TestCase | ||
|
||
context "Inspecting" do | ||
setup do | ||
@data = ("THIS IS BINARY " * 50).unpack("c*") | ||
end | ||
context "Inspecting" do | ||
setup do | ||
@data = ("THIS IS BINARY " * 50).unpack("c*") | ||
end | ||
|
||
should "not display actual data" do | ||
binary = Mongo::Binary.new(@data) | ||
assert_equal "<Mongo::Binary:#{binary.object_id}>", binary.inspect | ||
end | ||
should "not display actual data" do | ||
binary = Mongo::Binary.new(@data) | ||
assert_equal "<Mongo::Binary:#{binary.object_id}>", binary.inspect | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,58 @@ | ||
require 'test/test_helper' | ||
|
||
class ConnectionTest < Test::Unit::TestCase | ||
|
||
context "Basic operations: " do | ||
setup do | ||
@logger = mock() | ||
end | ||
context "Basic operations: " do | ||
setup do | ||
@logger = mock() | ||
end | ||
|
||
should "send update message" do | ||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false) | ||
@db = @conn['testing'] | ||
@coll = @db.collection('books') | ||
@conn.expects(:send_message).with do |op, msg, log| | ||
op == 2001 && log.include?("db.books.update") | ||
end | ||
@coll.update({}, {:title => 'Moby Dick'}) | ||
should "send update message" do | ||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false) | ||
@db = @conn['testing'] | ||
@coll = @db.collection('books') | ||
@conn.expects(:send_message).with do |op, msg, log| | ||
op == 2001 && log.include?("db.books.update") | ||
end | ||
@coll.update({}, {:title => 'Moby Dick'}) | ||
end | ||
|
||
should "send insert message" do | ||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false) | ||
@db = @conn['testing'] | ||
@coll = @db.collection('books') | ||
@conn.expects(:send_message).with do |op, msg, log| | ||
op == 2002 && log.include?("db.books.insert") | ||
end | ||
@coll.insert({:title => 'Moby Dick'}) | ||
should "send insert message" do | ||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false) | ||
@db = @conn['testing'] | ||
@coll = @db.collection('books') | ||
@conn.expects(:send_message).with do |op, msg, log| | ||
op == 2002 && log.include?("db.books.insert") | ||
end | ||
@coll.insert({:title => 'Moby Dick'}) | ||
end | ||
|
||
should "not log binary data" do | ||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false) | ||
@db = @conn['testing'] | ||
@coll = @db.collection('books') | ||
data = Mongo::Binary.new(("BINARY " * 1000).unpack("c*")) | ||
@conn.expects(:send_message).with do |op, msg, log| | ||
op == 2002 && log.include?("Mongo::Binary") | ||
end | ||
@coll.insert({:data => data}) | ||
should "not log binary data" do | ||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false) | ||
@db = @conn['testing'] | ||
@coll = @db.collection('books') | ||
data = Mongo::Binary.new(("BINARY " * 1000).unpack("c*")) | ||
@conn.expects(:send_message).with do |op, msg, log| | ||
op == 2002 && log.include?("Mongo::Binary") | ||
end | ||
@coll.insert({:data => data}) | ||
end | ||
|
||
should "send safe update message" do | ||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false) | ||
@db = @conn['testing'] | ||
@coll = @db.collection('books') | ||
@conn.expects(:send_message_with_safe_check).with do |op, msg, db_name, log| | ||
op == 2001 && log.include?("db.books.update") | ||
end | ||
@coll.update({}, {:title => 'Moby Dick'}, :safe => true) | ||
should "send safe update message" do | ||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false) | ||
@db = @conn['testing'] | ||
@coll = @db.collection('books') | ||
@conn.expects(:send_message_with_safe_check).with do |op, msg, db_name, log| | ||
op == 2001 && log.include?("db.books.update") | ||
end | ||
@coll.update({}, {:title => 'Moby Dick'}, :safe => true) | ||
end | ||
|
||
should "send safe insert message" do | ||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false) | ||
@db = @conn['testing'] | ||
@coll = @db.collection('books') | ||
@conn.expects(:send_message_with_safe_check).with do |op, msg, db_name, log| | ||
op == 2001 && log.include?("db.books.update") | ||
end | ||
@coll.update({}, {:title => 'Moby Dick'}, :safe => true) | ||
should "send safe insert message" do | ||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false) | ||
@db = @conn['testing'] | ||
@coll = @db.collection('books') | ||
@conn.expects(:send_message_with_safe_check).with do |op, msg, db_name, log| | ||
op == 2001 && log.include?("db.books.update") | ||
end | ||
@coll.update({}, {:title => 'Moby Dick'}, :safe => true) | ||
end | ||
end | ||
|
||
|
Oops, something went wrong.