Fix the build
This commit is contained in:
parent
aac8c31410
commit
80d54bb261
2 changed files with 5 additions and 52 deletions
|
@ -4,7 +4,7 @@ require 'vagrant-lxc/sudo_wrapper'
|
||||||
require 'vagrant-lxc/driver/cli'
|
require 'vagrant-lxc/driver/cli'
|
||||||
|
|
||||||
describe Vagrant::LXC::Driver::CLI do
|
describe Vagrant::LXC::Driver::CLI do
|
||||||
let(:sudo_wrapper) { double(Vagrant::LXC::SudoWrapper, run: true) }
|
let(:sudo_wrapper) { double(Vagrant::LXC::SudoWrapper, run: true, wrapper_path: nil) }
|
||||||
|
|
||||||
subject { described_class.new(sudo_wrapper) }
|
subject { described_class.new(sudo_wrapper) }
|
||||||
|
|
||||||
|
@ -110,26 +110,6 @@ describe Vagrant::LXC::Driver::CLI do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'shutdown' do
|
|
||||||
let(:name) { 'a-running-container' }
|
|
||||||
subject { described_class.new(sudo_wrapper, name) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
subject.stub(system: true)
|
|
||||||
allow(subject).to receive(:run)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'issues a lxc-shutdown with provided container name' do
|
|
||||||
subject.shutdown
|
|
||||||
expect(subject).to have_received(:run).with(:shutdown, '--name', name)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'raises a ShutdownNotSupported in case it is not supported' do
|
|
||||||
allow(subject).to receive(:system).with('which lxc-shutdown > /dev/null').and_return(false)
|
|
||||||
expect { subject.shutdown }.to raise_error(described_class::ShutdownNotSupported)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'stop' do
|
describe 'stop' do
|
||||||
let(:name) { 'a-running-container' }
|
let(:name) { 'a-running-container' }
|
||||||
subject { described_class.new(sudo_wrapper, name) }
|
subject { described_class.new(sudo_wrapper, name) }
|
||||||
|
@ -169,26 +149,6 @@ describe Vagrant::LXC::Driver::CLI do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'shutdown' do
|
|
||||||
let(:name) { 'a-running-container' }
|
|
||||||
subject { described_class.new(sudo_wrapper, name) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
subject.stub(system: true)
|
|
||||||
allow(subject).to receive(:run)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'issues a lxc-shutdown with provided container name' do
|
|
||||||
subject.shutdown
|
|
||||||
expect(subject).to have_received(:run).with(:shutdown, '--name', name)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'raises a ShutdownNotSupported in case it is not supported' do
|
|
||||||
allow(subject).to receive(:system).with('which lxc-shutdown > /dev/null').and_return(false)
|
|
||||||
expect { subject.shutdown }.to raise_error(described_class::ShutdownNotSupported)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'state' do
|
describe 'state' do
|
||||||
let(:name) { 'a-container' }
|
let(:name) { 'a-container' }
|
||||||
subject { described_class.new(sudo_wrapper, name) }
|
subject { described_class.new(sudo_wrapper, name) }
|
||||||
|
|
|
@ -113,7 +113,7 @@ describe Vagrant::LXC::Driver do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'halt' do
|
describe 'halt' do
|
||||||
let(:cli) { double(Vagrant::LXC::Driver::CLI, shutdown: true) }
|
let(:cli) { double(Vagrant::LXC::Driver::CLI, stop: true) }
|
||||||
|
|
||||||
subject { described_class.new('name', nil, cli) }
|
subject { described_class.new('name', nil, cli) }
|
||||||
|
|
||||||
|
@ -121,8 +121,8 @@ describe Vagrant::LXC::Driver do
|
||||||
allow(cli).to receive(:transition_to).and_yield(cli)
|
allow(cli).to receive(:transition_to).and_yield(cli)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'delegates to cli shutdown' do
|
it 'delegates to cli stop' do
|
||||||
expect(cli).to receive(:shutdown)
|
expect(cli).to receive(:stop)
|
||||||
subject.forced_halt
|
subject.forced_halt
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -133,14 +133,7 @@ describe Vagrant::LXC::Driver do
|
||||||
|
|
||||||
it 'attempts to force the container to stop in case a shutdown doesnt work' do
|
it 'attempts to force the container to stop in case a shutdown doesnt work' do
|
||||||
allow(cli).to receive(:shutdown).and_raise(Vagrant::LXC::Driver::CLI::TargetStateNotReached.new :target, :source)
|
allow(cli).to receive(:shutdown).and_raise(Vagrant::LXC::Driver::CLI::TargetStateNotReached.new :target, :source)
|
||||||
expect(cli).to receive(:transition_to).with(:stopped).twice
|
expect(cli).to receive(:transition_to).with(:stopped)
|
||||||
expect(cli).to receive(:stop)
|
|
||||||
subject.forced_halt
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'attempts to force the container to stop in case lxc-shutdown is not supported' do
|
|
||||||
allow(cli).to receive(:shutdown).and_raise(Vagrant::LXC::Driver::CLI::ShutdownNotSupported)
|
|
||||||
expect(cli).to receive(:transition_to).with(:stopped).twice
|
|
||||||
expect(cli).to receive(:stop)
|
expect(cli).to receive(:stop)
|
||||||
subject.forced_halt
|
subject.forced_halt
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue