From b1ae32416e83648cf5b29f0310a720c4de7b4ffa Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 23 Feb 2016 10:57:28 +0100 Subject: [PATCH] ruby: tests: use more asserts instead of manual checks Make more use of assert_equal/refute_equal instead of manually checking values and raising errors. --- ruby/t/tc_100_launch.rb | 4 +--- ruby/t/tc_410_close_event.rb | 8 ++------ ruby/t/tc_420_log_messages.rb | 4 +--- ruby/t/tc_810_rhbz664558c6.rb | 4 +--- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/ruby/t/tc_100_launch.rb b/ruby/t/tc_100_launch.rb index 9c31aa5c9..b79b984d8 100644 --- a/ruby/t/tc_100_launch.rb +++ b/ruby/t/tc_100_launch.rb @@ -30,9 +30,7 @@ class TestLoad < MiniTest::Unit::TestCase g.lvcreate("LV2", "VG", 200); lvs = g.lvs() - if lvs != ["/dev/VG/LV1", "/dev/VG/LV2"] - raise "incorrect lvs returned" - end + assert_equal ["/dev/VG/LV1", "/dev/VG/LV2"], lvs g.sync() end diff --git a/ruby/t/tc_410_close_event.rb b/ruby/t/tc_410_close_event.rb index c547613f7..be62b914f 100644 --- a/ruby/t/tc_410_close_event.rb +++ b/ruby/t/tc_410_close_event.rb @@ -29,12 +29,8 @@ class TestLoad < MiniTest::Unit::TestCase # Check that the close event is called. g.set_event_callback(close, Guestfs::EVENT_CLOSE) - if close_invoked != 0 - raise "close_invoked should be 0" - end + assert_equal 0, close_invoked g.close() - if close_invoked != 1 - raise "close_invoked should be 1" - end + assert_equal 1, close_invoked end end diff --git a/ruby/t/tc_420_log_messages.rb b/ruby/t/tc_420_log_messages.rb index 90a1360db..e64ea748d 100644 --- a/ruby/t/tc_420_log_messages.rb +++ b/ruby/t/tc_420_log_messages.rb @@ -45,8 +45,6 @@ class TestLoad < MiniTest::Unit::TestCase g.set_autosync(1) g.close() - if log_invoked == 0 - raise "log_invoked should be > 0" - end + refute_equal 0, log_invoked end end diff --git a/ruby/t/tc_810_rhbz664558c6.rb b/ruby/t/tc_810_rhbz664558c6.rb index 7e27db25c..347e403e1 100644 --- a/ruby/t/tc_810_rhbz664558c6.rb +++ b/ruby/t/tc_810_rhbz664558c6.rb @@ -38,8 +38,6 @@ class TestLoad < MiniTest::Unit::TestCase # This should call the close callback. g.close() - if close_invoked != 1 - raise "close_invoked should be 1" - end + assert_equal 1, close_invoked end end