mogilefs-client.git  about / heads / tags
MogileFS client library for Ruby
blob f20aacce14154369cecc3303fcac77a780170ecd 1038 bytes (raw)
$ git show pu:test/test_fresh.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
 
# -*- encoding: binary -*-
require "./test/fresh"

class TestMogFresh < Test::Unit::TestCase
  include TestFreshSetup
  alias setup setup_mogilefs
  alias teardown teardown_mogilefs

  def test_change_device_weight
    add_host_device_domain
    assert_equal true, @admin.change_device_weight("me", 1, 50)
    assert_equal 50, @admin.get_devices(1)[0]["weight"]
  end

  def test_list_keys_invalid_domain
    add_host_device_domain
    domain = @domain + ".non-existent"
    client = MogileFS::MogileFS.new :hosts => @hosts, :domain => domain
    assert_raises(MogileFS::Backend::UnregDomainError) do
      client.list_keys
    end
  end

  def test_invalid_key_exists
    add_host_device_domain
    domain = @domain + ".non-existent"
    client = MogileFS::MogileFS.new :hosts => @hosts, :domain => domain
    assert_raises(MogileFS::Backend::UnregDomainError) do
      client.exist?("FOO")
    end

    client = MogileFS::MogileFS.new :hosts => @hosts, :domain => @domain
    assert_equal false, client.exist?("non-existent")
  end
end

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