diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-12-18 20:19:15 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-12-18 20:19:15 -0800 |
commit | fa796bf60396430a3de4ce0409d7f1edf663856f (patch) | |
tree | c98bb5ab9508cc3d7fa832b5e98fef5933537252 /test/setup.rb | |
parent | 1b2589208ef8765ab17af06be3e12164ab7b1492 (diff) | |
download | mogilefs-client-fa796bf60396430a3de4ce0409d7f1edf663856f.tar.gz |
This allows us to reuse this code in another test
Diffstat (limited to 'test/setup.rb')
-rw-r--r-- | test/setup.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/setup.rb b/test/setup.rb index 5063d8f..b0dc53f 100644 --- a/test/setup.rb +++ b/test/setup.rb @@ -165,3 +165,43 @@ class TestMogileFS < Test::Unit::TestCase end +# for our mock results +class Array + alias_method :fetch_row, :shift +end + +class FakeMysql + attr_reader :expect + TBL_DEVICES = [ + # devid, hostip, altip, http_port, http_get_port + [ 1, '10.0.0.1', '192.168.0.1', 7500, 7600 ], + [ 2, '10.0.0.2', '192.168.0.2', 7500, 7600 ], + [ 3, '10.0.0.3', nil, 7500, nil ], + [ 4, '10.0.0.4', nil, 7500, nil ], + ] + TBL_DOMAINS = [ + # dmid, namespace + [ 1, 'test' ], + [ 2, 'foo' ], + ] + + def initialize + @expect = [] + end + + def quote(str) + str.to_s.gsub(/\\/, '\&\&').gsub(/'/, "''") + end + + def query(sql = '') + case sql + when MogileFS::Mysql::GET_DEVICES then TBL_DEVICES + when MogileFS::Mysql::GET_DOMAINS then TBL_DOMAINS + else + @expect.shift + end + end + +end + + |