mogilefs-client.git  about / heads / tags
MogileFS client library for Ruby
blob 6c62e6bd352bea7de103d3aee6320221d53fce2a 986 bytes (raw)
$ git show pipeline:test/test_mogilefs_integration_list_keys.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 

# -*- 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_list_keys_strange
    @client.store_content("hello+world", nil, "HI")
    rv = @client.list_keys
    assert_equal "hello+world", rv[0][0]
  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

git clone https://yhbt.net/mogilefs-client.git