1
0
Fork 0
mirror of https://github.com/nishiki/is_master.git synced 2024-10-27 01:53:16 +00:00
is_master/test/test_cli_slave.rb

34 lines
783 B
Ruby
Raw Normal View History

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