Branching mogilefs-client to version 1.2.1
[ruby-mogilefs-client.git] / test / test_client.rb
blob93d1522ea9f7d035f79eff44891d5678275c8df8
1 require 'test/unit'
3 $TESTING = true
5 require 'mogilefs'
7 class TestClient < Test::Unit::TestCase
9   def setup
10     @client = MogileFS::Client.new :hosts => ['kaa:6001']
11   end
13   def test_initialize
14     client = MogileFS::Client.new :hosts => ['kaa:6001']
15     assert_not_nil client
16     assert_instance_of MogileFS::Backend, client.backend
17     assert_equal ['kaa:6001'], client.hosts
19     client = MogileFS::Client.new :hosts => ['kaa:6001'], :timeout => 5
20     assert_equal 5, client.backend.timeout
21   end
23   def test_err
24     @client.backend.lasterr = 'you'
25     assert_equal 'you', @client.err
26   end
28   def test_errstr
29     @client.backend.lasterrstr = 'totally suck'
30     assert_equal 'totally suck', @client.errstr
31   end
33   def test_reload
34     orig_backend = @client.backend
36     @client.hosts = ['ziz:6001']
37     @client.reload
39     assert_not_same @client.backend, orig_backend
40     assert_equal ['ziz:6001'], @client.backend.hosts
41   end
43   def test_readonly_eh_readonly
44     client = MogileFS::Client.new :hosts => ['kaa:6001'], :readonly => true
45     assert_equal true, client.readonly?
46   end
48   def test_readonly_eh_readwrite
49     assert_equal false, @client.readonly?
50   end
52 end