mongo-ruby-driver/test/grid_io_test.rb

36 lines
843 B
Ruby
Raw Normal View History

2010-02-12 23:03:07 +00:00
require 'test/test_helper'
class GridIOTest < Test::Unit::TestCase
include GridFS
def setup
@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')
end
def teardown
@files.remove
@chunks.remove
end
context "Options" do
setup do
@filename = 'test'
@mode = 'w'
end
should "set default 256k chunk size" do
2010-02-18 21:31:25 +00:00
file = GridIO.new(@files, @chunks, @filename, @mode, false)
2010-02-12 23:03:07 +00:00
assert_equal 256 * 1024, file.chunk_size
end
should "set chunk size" do
2010-02-18 21:31:25 +00:00
file = GridIO.new(@files, @chunks, @filename, @mode, false, :chunk_size => 1000)
2010-02-12 23:03:07 +00:00
assert_equal 1000, file.chunk_size
end
end
end