Class: SusiTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- SusiTest
- Defined in:
- lib/susi.rb
Instance Method Summary collapse
- #run_command(cmd) ⇒ Object
- #test_cli_clone_img ⇒ Object
- #test_cli_clone_img_fail ⇒ Object
- #test_cli_create_img ⇒ Object
- #test_cli_create_img_fail ⇒ Object
- #test_cli_empty ⇒ Object
- #test_clone_img ⇒ Object
- #test_create_img ⇒ Object
Instance Method Details
#run_command(cmd) ⇒ Object
103 104 105 |
# File 'lib/susi.rb', line 103 def run_command(cmd) system("#{cmd} > /dev/null 2>&1") end |
#test_cli_clone_img ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/susi.rb', line 150 def test_cli_clone_img assert_equal(true, run_command("ruby ./bin/susi disk create test 1")) assert_equal(true, run_command("ruby ./bin/susi disk clone test clone")) assert(File.exist?("clone.qcow2")) run_command("rm clone.qcow2") run_command("rm test.qcow2") end |
#test_cli_clone_img_fail ⇒ Object
158 159 160 161 162 163 164 165 166 167 |
# File 'lib/susi.rb', line 158 def test_cli_clone_img_fail assert_equal(false, run_command("ruby ./bin/susi disk clone test clone")) assert_equal(true, run_command("ruby ./bin/susi disk create test 1")) assert_equal(false, run_command("ruby ./bin/susi disk clone test")) assert_equal(true, run_command("ruby ./bin/susi disk clone test clone")) assert_equal(false, run_command("ruby ./bin/susi disk clone test clone")) run_command("rm clone.qcow2") run_command("rm test.qcow2") end |
#test_cli_create_img ⇒ Object
123 124 125 126 127 |
# File 'lib/susi.rb', line 123 def test_cli_create_img assert_equal(true, run_command("ruby ./bin/susi disk create test 1")) assert(File.exist?("test.qcow2")) run_command("rm test.qcow2") end |
#test_cli_create_img_fail ⇒ Object
129 130 131 132 133 |
# File 'lib/susi.rb', line 129 def test_cli_create_img_fail assert_equal(false, run_command("ruby ./bin/susi disk create test")) assert_equal(false, run_command("ruby ./bin/susi disk create test pest")) assert_equal(false, run_command("ruby ./bin/susi disk create 1")) end |
#test_cli_empty ⇒ Object
107 108 109 |
# File 'lib/susi.rb', line 107 def test_cli_empty assert_equal(false, run_command("ruby ./bin/susi")) end |
#test_clone_img ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/susi.rb', line 135 def test_clone_img Susi::Disk.create("test", "1") Susi::Disk.clone("test", "clone") assert(File.exist?("clone.qcow2")) info = `qemu-img info clone.qcow2` assert(info.include?("virtual size: 1 GiB")) assert(info.include?("format: qcow2")) assert(info.include?("backing file: test.qcow2")) assert(info.include?("backing file format: qcow2")) run_command("rm clone.qcow2") run_command("rm test.qcow2") end |
#test_create_img ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/susi.rb', line 111 def test_create_img Susi::Disk.create("test", "1") # check created file assert(File.exist?("test.qcow2")) info = `qemu-img info test.qcow2` assert(info.include?("virtual size: 1 GiB")) assert(info.include?("format: qcow2")) run_command("rm test.qcow2") end |