mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
49 lines
1.5 KiB
Ruby
49 lines
1.5 KiB
Ruby
|
|
require 'spec_helper'
|
||
|
|
require 'support/sharedcontext'
|
||
|
|
|
||
|
|
require 'vagrant-libvirt/action/clean_machine_folder'
|
||
|
|
|
||
|
|
describe VagrantPlugins::ProviderLibvirt::Action::CleanMachineFolder do
|
||
|
|
subject { described_class.new(app, env) }
|
||
|
|
|
||
|
|
include_context 'unit'
|
||
|
|
|
||
|
|
describe '#call' do
|
||
|
|
context 'with default options' do
|
||
|
|
it 'should verbosely remove the folder' do
|
||
|
|
expect(ui).to receive(:info).with('Deleting the machine folder')
|
||
|
|
expect(FileUtils).to receive(:rm_rf).with(machine.data_dir, {:secure => true})
|
||
|
|
|
||
|
|
expect(subject.call(env)).to be_nil
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
context 'when the data dir doesn\'t exist' do
|
||
|
|
before do
|
||
|
|
Dir.mktmpdir do |d|
|
||
|
|
# returns a temporary directory that has been already deleted when running
|
||
|
|
expect(machine).to receive(:data_dir).and_return(d.to_s).exactly(2).times
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
it 'should remove the folder' do
|
||
|
|
expect(ui).to receive(:info).with('Deleting the machine folder')
|
||
|
|
expect(FileUtils).to receive(:rm_rf).with(machine.data_dir, {:secure => true})
|
||
|
|
|
||
|
|
expect(subject.call(env)).to be_nil
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
context 'with quiet option enabled' do
|
||
|
|
subject { described_class.new(app, env, {:quiet => true}) }
|
||
|
|
|
||
|
|
it 'should quietly remove the folder' do
|
||
|
|
expect(ui).to_not receive(:info).with('Deleting the machine folder')
|
||
|
|
expect(FileUtils).to receive(:rm_rf).with(machine.data_dir, {:secure => true})
|
||
|
|
|
||
|
|
expect(subject.call(env)).to be_nil
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|