mogilefs-client.git  about / heads / tags
MogileFS client library for Ruby
blob cbf298affcc0917794f1a58e275f0709c368816f 1337 bytes (raw)
$ git show HEAD:test/test_client.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 
# -*- encoding: binary -*-
require 'test/unit'
require 'mogilefs'

class MogileFS::Backend
  attr_accessor :timeout, :hosts
  attr_writer :lasterr, :lasterrstr
end

class MogileFS::Client
  attr_accessor :hosts
end

class TestClient < Test::Unit::TestCase

  def setup
    @client = MogileFS::Client.new :hosts => ['kaa:6001']
  end

  def test_initialize
    client = MogileFS::Client.new :hosts => ['kaa:6001']
    assert_not_nil client
    assert_instance_of MogileFS::Backend, client.backend
    assert_equal ['kaa:6001'], client.hosts

    client = MogileFS::Client.new :hosts => ['kaa:6001'], :timeout => 5
    assert_equal 5, client.backend.timeout
  end

  def test_err
    @client.backend.lasterr = 'you'
    assert_equal 'you', @client.err
  end

  def test_errstr
    @client.backend.lasterrstr = 'totally suck'
    assert_equal 'totally suck', @client.errstr
  end

  def test_reload
    orig_backend = @client.backend

    @client.hosts = ['ziz:6001']
    @client.reload

    assert_not_same @client.backend, orig_backend
    assert_equal ['ziz:6001'], @client.backend.hosts
  end

  def test_readonly_eh_readonly
    client = MogileFS::Client.new :hosts => ['kaa:6001'], :readonly => true
    assert_equal true, client.readonly?
  end

  def test_readonly_eh_readwrite
    assert_equal false, @client.readonly?
  end

end


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