test/bson/object_id_test.rb in mongo-1.3.1 vs test/bson/object_id_test.rb in mongo-1.4.0
- old
+ new
@@ -1,14 +1,11 @@
-require './test/test_helper'
+require './test/bson/test_helper'
require 'rubygems'
require 'json'
class ObjectIdTest < Test::Unit::TestCase
- include Mongo
- include BSON
-
def setup
@o = ObjectId.new
end
def test_hashcode
@@ -63,22 +60,10 @@
def test_inspect
assert_equal "BSON::ObjectId('#{@o.to_s}')", @o.inspect
end
- def test_save_and_restore
- db = standard_connection.db(MONGO_TEST_DB)
- coll = db.collection('test')
-
- coll.remove
- coll << {'a' => 1, '_id' => @o}
-
- row = coll.find().collect.first
- assert_equal 1, row['a']
- assert_equal @o, row['_id']
- end
-
def test_from_string
hex_str = @o.to_s
o2 = ObjectId.from_string(hex_str)
assert_equal hex_str, o2.to_s
assert_equal @o, o2
@@ -132,11 +117,10 @@
def test_from_time_unique
time = Time.now.utc
id = ObjectId.from_time(time, :unique => true)
- mac_id = Digest::MD5.digest(Socket.gethostname)[0, 3].unpack("C3")
- assert_equal id.to_a[4, 3], mac_id
+ assert_equal id.to_a[4, 3], ObjectId.machine_id.unpack("C3")
assert_equal time.to_i, id.generation_time.to_i
id2 = ObjectId.new(nil, time)
assert_equal time.to_i, id2.generation_time.to_i
end