Add delete vm action checks for data directory removal and creation

This commit is contained in:
Chris Roberts 2018-06-18 10:18:05 -07:00
parent 69ece0db4e
commit ed2af17e45
1 changed files with 13 additions and 1 deletions

View File

@ -8,13 +8,15 @@ describe VagrantPlugins::HyperV::Action::DeleteVM do
let(:ui){ double("ui") }
let(:provider){ double("provider", driver: driver) }
let(:driver){ double("driver") }
let(:machine){ double("machine", provider: provider) }
let(:machine){ double("machine", provider: provider, data_dir: "/dev/null") }
let(:subject){ described_class.new(app, env) }
before do
allow(app).to receive(:call)
allow(ui).to receive(:info)
allow(driver).to receive(:delete_vm)
allow(FileUtils).to receive(:rm_rf)
allow(FileUtils).to receive(:mkdir_p)
end
it "should call the app on success" do
@ -26,4 +28,14 @@ describe VagrantPlugins::HyperV::Action::DeleteVM do
expect(driver).to receive(:delete_vm)
subject.call(env)
end
it "should delete the data directory" do
expect(FileUtils).to receive(:rm_rf).with(machine.data_dir)
subject.call(env)
end
it "should recreate the data directory" do
expect(FileUtils).to receive(:mkdir_p).with(machine.data_dir)
subject.call(env)
end
end