minor: test fix

This commit is contained in:
Kyle Banker 2010-02-12 18:41:34 -05:00
parent f158aa13af
commit 32606db5e9
3 changed files with 6 additions and 13 deletions

View File

@ -58,5 +58,6 @@ require 'mongo/connection'
require 'mongo/cursor'
require 'mongo/db'
require 'mongo/exceptions'
require 'mongo/gridfs'
require 'mongo/gridfs/grid'
require 'mongo/gridfs/grid_io'

View File

@ -167,10 +167,6 @@ module Mongo
chunk || {}
end
def delete_chunks(selector)
@chunks.remove(selector)
end
def last_chunk_number
(@file_length / @chunk_size).to_i
end
@ -215,7 +211,7 @@ module Mongo
@current_chunk = get_chunk(0)
@file_position = 0
when 'w'
delete_chunks({'_files_id' => })
@chunks.remove({'_files_id' => @files_id})
@metadata = opts[:metadata] if opts[:metadata]
@chunks.create_index([['files_id', Mongo::ASCENDING], ['n', Mongo::ASCENDING]])

View File

@ -1,7 +1,6 @@
require 'test/test_helper'
class GridTest < Test::Unit::TestCase
include GridFS
def setup
@db ||= Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
@ -17,18 +16,15 @@ class GridTest < Test::Unit::TestCase
context "When reading:" do
setup do
@data = "CHUNKS" * 50000
GridStore.open(@db, 'sample', 'w') do |f|
f.puts @data
@data = "CHUNKS" * 50000
@grid = Grid.new(@db)
@grid.open('sample', 'w') do |f|
f.write @data
end
@grid = Grid.new(@db)
end
should "contain sample data" do
assert_equal @data, GridStore.read(@db, 'sample')
end
should "read sample data" do
data = @grid.open('sample', 'r') { |f| f.read }
assert_equal data.length, @data.length