1
0
Fork 0
mirror of https://github.com/nishiki/is_master.git synced 2025-02-23 06:30:13 +00:00
is_master/test/test_cli_slave.rb

34 lines
783 B
Ruby
Raw Normal View History

2017-11-09 11:35:27 +01:00
require 'test/unit'
2018-02-24 10:00:09 +01:00
class TestCliSlave < Test::Unit::TestCase
2017-12-15 13:40:12 +01:00
def test_missing_arg
2018-02-24 10:00:09 +01:00
output = %x(is_slave 127.0.0.1)
2017-12-15 13:40:12 +01:00
assert_match('Usage: ', output)
2018-02-24 10:00:09 +01:00
output = %x(is_slave)
2017-12-15 13:40:12 +01:00
assert_match('Usage: ', output)
end
2017-11-09 11:35:27 +01:00
def test_slave_mode
2018-02-24 10:00:09 +01:00
output = %x(is_slave 10.255.255.0 echo 'GOOD!')
assert_match('GOOD!', output)
2017-11-09 11:35:27 +01:00
end
def test_master_mode
2018-02-24 10:00:09 +01:00
output = %x(is_slave 127.0.0.1 echo 'GOOD!')
assert_match('I am master', output)
2017-11-09 11:35:27 +01:00
end
2017-11-10 08:01:18 +01:00
2017-12-15 13:40:12 +01:00
def test_file_slave_mode
2018-02-24 10:00:09 +01:00
output = %x(is_slave /tmp/test.txt echo 'GOOD!')
assert_match('GOOD!', output)
2017-12-15 13:40:12 +01:00
end
2017-11-10 08:01:18 +01:00
2017-12-15 13:40:12 +01:00
def test_file_master_mode
File.write('/tmp/test.txt', '')
2018-02-24 10:00:09 +01:00
output = %x(is_slave /tmp/test.txt echo 'GOOD!')
assert_match('I am master', output)
2017-12-15 13:40:12 +01:00
File.unlink('/tmp/test.txt')
2017-11-10 08:01:18 +01:00
end
2017-11-09 11:35:27 +01:00
end