test/virtualbox/vm_test.rb in virtualbox-0.3.0 vs test/virtualbox/vm_test.rb in virtualbox-0.4.0
- old
+ new
@@ -87,20 +87,26 @@
def create_vm
VirtualBox::Command.expects(:vboxmanage).with("showvminfo #{@name} --machinereadable").returns(@raw)
VirtualBox::Command.expects(:vboxmanage).with("showvminfo #{@name}").returns("")
VirtualBox::Command.expects(:vboxmanage).with("list hdds").returns("")
VirtualBox::Command.expects(:vboxmanage).with("list dvds").returns("")
+ VirtualBox::Command.expects(:vboxmanage).with("getextradata #{@name} enumerate").returns("")
vm = VirtualBox::VM.find(@name)
assert vm
vm
end
context "human readable info" do
should "not pass --machinereadable into the showvminfo command" do
VirtualBox::Command.expects(:vboxmanage).with("showvminfo #{@name}").once
VirtualBox::VM.human_info(@name)
end
+
+ should "shell escape parameter" do
+ VirtualBox::Command.expects(:vboxmanage).with("showvminfo hello\\ world").once
+ VirtualBox::VM.human_info("hello world")
+ end
end
context "reading the VM state" do
setup do
@vm = create_vm
@@ -357,10 +363,12 @@
should "save the relationships as well" do
VirtualBox::Nic.expects(:save_relationship).once
VirtualBox::StorageController.expects(:save_relationship).once
VirtualBox::SharedFolder.expects(:save_relationship).once
+ VirtualBox::ExtraData.expects(:save_relationship).once
+ VirtualBox::ForwardedPort.expects(:save_relationship).once
assert @vm.save
end
end
context "finding a VM by name" do
@@ -375,9 +383,14 @@
command_seq = sequence("command_seq)")
VirtualBox::Command.expects(:vboxmanage).with("showvminfo #{@name} --machinereadable").returns(@raw).in_sequence(command_seq)
VirtualBox::Command.expects(:vboxmanage).with(anything).returns("").at_least(0).in_sequence(command_seq)
@vm = VirtualBox::VM.find(@name)
assert @vm
+ end
+
+ should "shell escape the VM name" do
+ VirtualBox::Command.expects(:vboxmanage).with("showvminfo hello\\ world --machinereadable").returns(@raw)
+ assert VirtualBox::VM.find("hello world")
end
should "return a VM object with proper attributes" do
@expected.each do |k,v|
assert_equal v, @vm.read_attribute(k)
\ No newline at end of file