require File.join(File.dirname(__FILE__), '_lib.rb') class MoSQL::Test::Functional::SchemaTest < MoSQL::Test::Functional TEST_MAP = < "a", 'var' => 0}, {'_id' => "b", 'var' => 1}, {'_id' => "c"}, {'_id' => "d", 'other_var' => "hello"} ] @map.copy_data(@sequel, 'db.collection', objects.map { |o| @map.transform('db.collection', o) } ) assert_equal(4, table.count) rows = table.select.sort_by { |r| r[:_id] } assert_equal(%w[a b c d], rows.map { |r| r[:_id] }) assert_equal(nil, rows[2][:var]) assert_equal(nil, rows[3][:var]) end it 'Can COPY BSON::ObjectIDs' do o = {'_id' => BSON::ObjectId.new, 'var' => 0} @map.copy_data(@sequel, 'db.collection', [ @map.transform('db.collection', o)] ) assert_equal(o['_id'].to_s, table.select.first[:_id]) end it 'Can transform BSON::ObjectIDs' do o = {'_id' => BSON::ObjectId.new, 'var' => 0} row = @map.transform('db.collection', o) table.insert(row) assert_equal(o['_id'].to_s, table.select.first[:_id]) end end