mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
ruby: tests: convert from Test::Unit to MiniTest (RHBZ#1085029)
Convert the tests to the MiniTest test framework, but keeping the usage of the old Test::Unit as fallback in case MiniTest is not available. In the latter case, use a bit of "glue" to make the old API look like the new API, so we can just rely on the newer MiniTest API.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_load
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_create
|
||||
g = Guestfs::Guestfs.new()
|
||||
assert_not_nil (g)
|
||||
refute_nil (g)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_create_flags
|
||||
g = Guestfs::Guestfs.new(:environment => false, :close_on_exit => true)
|
||||
assert_not_nil (g)
|
||||
refute_nil (g)
|
||||
g.parse_environment()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_create_multiple
|
||||
g1 = Guestfs::Guestfs.new()
|
||||
g2 = Guestfs::Guestfs.new()
|
||||
g3 = Guestfs::Guestfs.new()
|
||||
assert_not_nil (g1)
|
||||
assert_not_nil (g2)
|
||||
assert_not_nil (g3)
|
||||
refute_nil (g1)
|
||||
refute_nil (g2)
|
||||
refute_nil (g3)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_handle_properties
|
||||
g = Guestfs::Guestfs.new()
|
||||
assert_not_nil (g)
|
||||
refute_nil (g)
|
||||
v = g.get_verbose()
|
||||
g.set_verbose(v)
|
||||
v = g.get_trace()
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_explicit_close
|
||||
g = Guestfs::Guestfs.new()
|
||||
assert_not_nil (g)
|
||||
refute_nil (g)
|
||||
g.close()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_optargs
|
||||
g = Guestfs::Guestfs.new()
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_launch
|
||||
g = Guestfs::Guestfs.new()
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_events
|
||||
g = Guestfs::Guestfs.new()
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_events
|
||||
g = Guestfs::Guestfs.new()
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_rhbz507346
|
||||
g = Guestfs::Guestfs.new()
|
||||
g.add_drive_scratch(10*1024*1024)
|
||||
g.launch()
|
||||
|
||||
exception = assert_raise TypeError do
|
||||
exception = assert_raises TypeError do
|
||||
g.command(1)
|
||||
end
|
||||
assert_match /wrong argument type Fixnum \(expected Array\)/, exception.message
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def test_rhbz664558c6
|
||||
g = Guestfs::Guestfs.new()
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
require File::join(File::dirname(__FILE__), 'test_helper')
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
class TestLoad < MiniTest::Unit::TestCase
|
||||
def _handleok(g)
|
||||
g.add_drive("/dev/null")
|
||||
g.close()
|
||||
|
||||
@@ -15,7 +15,18 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
require 'test/unit'
|
||||
begin
|
||||
require 'minitest/autorun'
|
||||
rescue LoadError
|
||||
require 'test/unit'
|
||||
MiniTest = Test
|
||||
module Test
|
||||
Assertions = Unit::Assertions
|
||||
module Assertions
|
||||
alias refute_nil assert_not_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
|
||||
$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs"))
|
||||
|
||||
Reference in New Issue
Block a user