mongo-ruby-driver/test/grid_io_test.rb

38 lines
900 B
Ruby
Raw Normal View History

2010-02-12 23:03:07 +00:00
require 'test/test_helper'
2010-02-20 00:17:38 +00:00
include Mongo
2010-02-12 23:03:07 +00:00
2010-02-22 20:49:04 +00:00
class GridIOTest < Test::Unit::TestCase
2010-02-12 23:03:07 +00:00
2010-02-22 20:49:04 +00:00
context "GridIO" do
2010-02-12 23:03:07 +00:00
setup do
2010-02-22 20:49:04 +00:00
@db ||= Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT).db('ruby-mongo-test')
@files = @db.collection('fs.files')
@chunks = @db.collection('fs.chunks')
2010-02-12 23:03:07 +00:00
end
2010-02-22 20:49:04 +00:00
teardown do
@files.remove
@chunks.remove
2010-02-12 23:03:07 +00:00
end
2010-02-22 20:49:04 +00:00
context "Options" do
setup do
@filename = 'test'
@mode = 'w'
end
should "set default 256k chunk size" do
file = GridIO.new(@files, @chunks, @filename, @mode)
assert_equal 256 * 1024, file.chunk_size
end
should "set chunk size" do
file = GridIO.new(@files, @chunks, @filename, @mode, :chunk_size => 1000)
assert_equal 1000, file.chunk_size
end
2010-02-12 23:03:07 +00:00
end
end
2010-02-22 20:49:04 +00:00
2010-02-12 23:03:07 +00:00
end