1 # -*- encoding: binary -*-
2 require './test/rack_read_write.rb'
6 class Test_TDB < Test::Unit::TestCase
7 attr_reader :tmp, :o, :uri
8 include TestRackReadWrite
11 tmp = Tempfile.new('tdb')
12 @path_pattern = tmp.path + ".%01x.tdb"
15 @app_opts = { :uri => @uri, :path_pattern => @path_pattern }
18 def test_alternate_hash
20 @app = Metropolis.new(@app_opts.merge(:nr_slots => n, :multi_hash => :to_i))
21 req = Rack::MockRequest.new(app)
22 o = { :lint => true, :fatal => true, :input => "." }
24 r = req.put("/#{i * n}", o)
25 assert_equal 201, r.status
26 assert_equal "Created\n", r.body
28 tmp = Hash.new { |h,k| h[k] = {} }
30 @dbv.each_with_index { |db,i| db.each { |k,v| tmp[i][k] = v } }
44 assert_equal expect, tmp
48 Dir[@path_pattern.sub!(/%\d*x/, '*')].each { |x| File.unlink(x) }