diff options
Diffstat (limited to 'test/test_mogilefs_integration_list_keys.rb')
-rw-r--r-- | test/test_mogilefs_integration_list_keys.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test_mogilefs_integration_list_keys.rb b/test/test_mogilefs_integration_list_keys.rb new file mode 100644 index 0000000..bb3f94a --- /dev/null +++ b/test/test_mogilefs_integration_list_keys.rb @@ -0,0 +1,34 @@ + +# -*- encoding: binary -*- +require './test/integration' + +class TestMogileFSIntegrationListKeys < TestMogIntegration + def setup + super + @client = MogileFS::MogileFS.new(:hosts => @trackers, :domain => @domain) + end + + def test_list_keys + k = %w(a b c d e f g) + k.each { |x| @client.store_content("lk_#{x}", nil, x) } + expect = k.map { |x| "lk_#{x}" } + rv = @client.list_keys + assert_equal([ expect, expect.last ] , rv) + nr = 0 + @client.list_keys do |key, length, devcount| + assert_equal 1, length + assert_kind_of Integer, devcount + assert_equal expect[nr], key + nr += 1 + end + end + + def test_each_key + 9.times { |i| @client.store_content("ek_#{i}", nil, i.to_s) } + n = 0 + @client.each_key do |key| + assert_equal "ek_#{n.to_s}", key + n += 1 + end + end +end |