From da534c3b0e273677c6c694cc903cd0b8d078f7b5 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 2 Mar 2013 01:20:27 -0300 Subject: [PATCH] lxc-shutdown: check --- lib/vagrant-lxc/container.rb | 3 ++- spec/unit/container_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/vagrant-lxc/container.rb b/lib/vagrant-lxc/container.rb index 0806849..f292f90 100644 --- a/lib/vagrant-lxc/container.rb +++ b/lib/vagrant-lxc/container.rb @@ -42,7 +42,8 @@ module Vagrant end def halt - update!(:poweroff) + lxc :shutdown, '--name', @name + wait_until :stopped end def destroy diff --git a/spec/unit/container_spec.rb b/spec/unit/container_spec.rb index 954e462..86c1dbc 100644 --- a/spec/unit/container_spec.rb +++ b/spec/unit/container_spec.rb @@ -117,6 +117,26 @@ describe Vagrant::LXC::Container do end end + describe 'halt' do + let(:name) { 'random-container-name' } + + before do + subject.stub(lxc: true, wait_until: true) + subject.halt + end + + it 'calls lxc-shutdown with the right arguments' do + subject.should have_received(:lxc).with( + :shutdown, + '--name', name + ) + end + + it 'waits for container state to be STOPPED' do + subject.should have_received(:wait_until).with(:stopped) + end + end + describe 'state' do let(:name) { 'random-container-name' }