minor: test cleanup and fixes
This commit is contained in:
parent
01f28b47ff
commit
e9e0e47cc1
|
@ -3,19 +3,21 @@ require './test/bson/test_helper'
|
|||
require 'set'
|
||||
|
||||
if RUBY_VERSION < '1.9'
|
||||
require 'complex'
|
||||
require 'rational'
|
||||
silently do
|
||||
require 'complex'
|
||||
require 'rational'
|
||||
end
|
||||
end
|
||||
require 'bigdecimal'
|
||||
|
||||
begin
|
||||
require 'date'
|
||||
require 'tzinfo'
|
||||
require 'active_support/core_ext'
|
||||
require 'active_support/timezone'
|
||||
Time.zone = "Pacific Time (US & Canada)"
|
||||
Zone = Time.zone.now
|
||||
rescue LoadError
|
||||
warn 'Mocking time with zone'
|
||||
#warn 'Mocking time with zone'
|
||||
module ActiveSupport
|
||||
class TimeWithZone
|
||||
def initialize(utc_time, zone)
|
||||
|
@ -278,6 +280,7 @@ class BSONTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_date_before_epoch
|
||||
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ then return true end
|
||||
begin
|
||||
doc = {'date' => Time.utc(1600)}
|
||||
bson = @encoder.serialize(doc)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require './test/test_helper'
|
||||
require 'rbconfig'
|
||||
|
||||
class TestCollection < Test::Unit::TestCase
|
||||
@@connection ||= standard_connection(:op_timeout => 10)
|
||||
|
@ -223,12 +224,15 @@ class TestCollection < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_bson_invalid_encoding_serialize_error_with_collect_on_error
|
||||
# Broken for current JRuby
|
||||
if RUBY_PLATFORM == 'java' then return end
|
||||
docs = []
|
||||
docs << {:foo => 1}
|
||||
docs << {:bar => 1}
|
||||
invalid_docs = []
|
||||
invalid_docs << {"\223\372\226{" => 1} # non utf8 encoding
|
||||
docs += invalid_docs
|
||||
invalid_docs << {"\223\372\226}" => 1} # non utf8 encoding
|
||||
docs += invalid_docs
|
||||
|
||||
assert_raise BSON::InvalidStringEncoding do
|
||||
@@test.insert(docs, :collect_on_error => false)
|
||||
end
|
||||
|
@ -657,6 +661,7 @@ class TestCollection < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_saving_dates_pre_epoch
|
||||
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ then return true end
|
||||
begin
|
||||
@@test.save({'date' => Time.utc(1600)})
|
||||
assert_in_delta Time.utc(1600), @@test.find_one()["date"], 2
|
||||
|
|
|
@ -2,7 +2,7 @@ require './test/test_helper'
|
|||
include Mongo
|
||||
|
||||
def read_and_write_stream(filename, read_length, opts={})
|
||||
io = File.open(File.join(File.dirname(__FILE__), 'data', filename), 'r')
|
||||
io = File.open(File.join(File.dirname(__FILE__), 'data', filename), 'r+b')
|
||||
id = @grid.put(io, opts.merge!(:filename => filename + read_length.to_s))
|
||||
file = @grid.get(id)
|
||||
io.rewind
|
||||
|
|
|
@ -73,7 +73,7 @@ class TestThreading < Test::Unit::TestCase
|
|||
@@coll = @@db.collection('thread-test-collection')
|
||||
|
||||
1000.times do |i|
|
||||
@@coll.insert("x" => i)
|
||||
@@coll.insert("x" => i, :safe => true)
|
||||
end
|
||||
|
||||
threads = []
|
||||
|
|
Loading…
Reference in New Issue