Branching mogilefs-client to version 1.2.1
[ruby-mogilefs-client.git] / test / setup.rb
blob86f0f2838ef05447c4b05bc139b14bb8a93f1e40
1 require 'test/unit'
3 $TESTING = true
5 require 'mogilefs'
7 class FakeBackend
9   attr_reader :lasterr, :lasterrstr
11   def initialize
12     @responses = Hash.new { |h,k| h[k] = [] }
13     @lasterr = nil
14     @lasterrstr = nil
15   end
17   def method_missing(meth, *args)
18     meth = meth.to_s
19     if meth =~ /(.*)=$/ then
20       @responses[$1] << args.first
21     else
22       response = @responses[meth].shift
23       case response
24       when Array then
25         @lasterr = response.first
26         @lasterrstr = response.last
27         return nil
28       end
29       return response
30     end
31   end
33 end
35 class MogileFS::Client
36   attr_writer :readonly
37 end
39 class TestMogileFS < Test::Unit::TestCase
41   def setup
42     return if self.class == TestMogileFS
43     @root = '/mogilefs/test'
44     @client = @klass.new :hosts => ['kaa:6001'], :domain => 'test',
45                                   :root => @root
46     @backend = FakeBackend.new
47     @client.instance_variable_set '@backend', @backend
48   end
50   def test_nothing
51   end
53 end