Mock out storage controllers
This commit is contained in:
parent
8407d79100
commit
8739c04aa9
@ -26,8 +26,8 @@ module VagrantPlugins
|
||||
# @param [VagrantPlugins::Kernel_V2::VagrantConfigDisk] defined_disks
|
||||
# @param [Hash] disk_meta - A hash of all the previously defined disks from the last configure_disk action
|
||||
def self.handle_cleanup_disk(machine, defined_disks, disk_meta)
|
||||
vm_info = machine.provider.driver.show_vm_info
|
||||
primary_disk = vm_info["SATA Controller-ImageUUID-0-0"]
|
||||
storage_controller = machine.provider.driver.storage_controllers.detect { |c| c[:type] == "IntelAhci" }
|
||||
primary_disk = storage_controller[:attachments].detect { |a| a[:port] == "0" && a[:device] == "0" }[:uuid]
|
||||
|
||||
unless disk_meta.nil?
|
||||
disk_meta.each do |d|
|
||||
|
||||
@ -33,8 +33,11 @@ describe VagrantPlugins::ProviderVirtualBox::Cap::CleanupDisks do
|
||||
let(:vm_info) { {"SATA Controller-ImageUUID-0-0" => "12345",
|
||||
"SATA Controller-ImageUUID-1-0" => "67890"} }
|
||||
|
||||
let(:storage_controllers) {
|
||||
}
|
||||
let(:storage_controllers) { [{name: "SATA Controller",
|
||||
type: "IntelAhci",
|
||||
maxportcount: 30,
|
||||
attachments: [{port: "0", device: "0", uuid: "12345"},
|
||||
{port: "1", device: "0", uuid: "67890"}]}] }
|
||||
|
||||
before do
|
||||
allow(Vagrant::Util::Experimental).to receive(:feature_enabled?).and_return(true)
|
||||
@ -104,6 +107,10 @@ describe VagrantPlugins::ProviderVirtualBox::Cap::CleanupDisks do
|
||||
|
||||
describe "#handle_cleanup_dvd" do
|
||||
let(:vm_info) { {"IDE Controller-ImageUUID-0-0" => "1234" } }
|
||||
let(:storage_controllers) { [{name: "IDE Controller",
|
||||
type: "PIIX4",
|
||||
maxportcount: 2,
|
||||
attachments: [{port: "0", device: "0", uuid: "1234"}]}] }
|
||||
let(:disk_meta_file) { {dvd: [{"uuid" => "1234", "name" => "iso"}]} }
|
||||
let(:defined_disks) { [] }
|
||||
|
||||
@ -117,6 +124,12 @@ describe VagrantPlugins::ProviderVirtualBox::Cap::CleanupDisks do
|
||||
let(:vm_info) { {"IDE Controller-ImageUUID-0-0" => "1234",
|
||||
"IDE Controller-ImageUUID-0-1" => "1234"} }
|
||||
|
||||
let(:storage_controllers) { [{name: "IDE Controller",
|
||||
type: "PIIX4",
|
||||
maxportcount: 2,
|
||||
attachments: [{port: "0", device: "0", uuid: "1234"},
|
||||
{port: "0", device: "1", uuid: "1234"}]}] }
|
||||
|
||||
it "removes all media with that UUID" do
|
||||
expect(driver).to receive(:remove_disk).with("0", "0", "IDE Controller").and_return(true)
|
||||
expect(driver).to receive(:remove_disk).with("0", "1", "IDE Controller").and_return(true)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user