get_uri: object allocation reduction
[ruby-mogilefs-client.git] / test / test_mogilefs_integration_list_keys.rb
blobbb3f94af49abf315fdf4e293d27b12b15e49d975
2 # -*- encoding: binary -*-
3 require './test/integration'
5 class TestMogileFSIntegrationListKeys < TestMogIntegration
6   def setup
7     super
8     @client = MogileFS::MogileFS.new(:hosts => @trackers, :domain => @domain)
9   end
11   def test_list_keys
12     k = %w(a b c d e f g)
13     k.each { |x| @client.store_content("lk_#{x}", nil, x) }
14     expect = k.map { |x| "lk_#{x}" }
15     rv = @client.list_keys
16     assert_equal([ expect, expect.last ] , rv)
17     nr = 0
18     @client.list_keys do |key, length, devcount|
19       assert_equal 1, length
20       assert_kind_of Integer, devcount
21       assert_equal expect[nr], key
22       nr += 1
23     end
24   end
26   def test_each_key
27     9.times { |i| @client.store_content("ek_#{i}", nil, i.to_s) }
28     n = 0
29     @client.each_key do |key|
30       assert_equal "ek_#{n.to_s}", key
31       n += 1
32     end
33   end
34 end