minor: test fix
This commit is contained in:
parent
f158aa13af
commit
32606db5e9
|
@ -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'
|
||||
|
|
|
@ -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]])
|
||||
|
|
|
@ -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',
|
||||
|
@ -18,17 +17,14 @@ class GridTest < Test::Unit::TestCase
|
|||
context "When reading:" do
|
||||
setup do
|
||||
@data = "CHUNKS" * 50000
|
||||
GridStore.open(@db, 'sample', 'w') do |f|
|
||||
f.puts @data
|
||||
@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
|
||||
|
|
Loading…
Reference in New Issue