2013-03-30 22:18:05 +00:00
|
|
|
require 'unit_helper'
|
|
|
|
|
2014-03-11 22:50:28 +00:00
|
|
|
require 'vagrant-lxc/plugin'
|
|
|
|
require 'vagrant-lxc/provider'
|
2013-03-30 22:18:05 +00:00
|
|
|
require 'vagrant-lxc/action/compress_rootfs'
|
|
|
|
|
|
|
|
describe Vagrant::LXC::Action::CompressRootFS do
|
2013-07-13 16:41:39 +00:00
|
|
|
let(:app) { double(:app, call: true) }
|
|
|
|
let(:env) { {machine: machine, ui: double(info: true)} }
|
2014-03-11 22:50:28 +00:00
|
|
|
let(:machine) { double(Vagrant::Machine, provider: provider) }
|
|
|
|
let(:provider) { double(Vagrant::LXC::Provider, driver: driver) }
|
|
|
|
let(:driver) { double(Vagrant::LXC::Driver, compress_rootfs: compressed_rootfs_path) }
|
2013-03-30 22:18:05 +00:00
|
|
|
let(:compressed_rootfs_path) { '/path/to/rootfs.tar.gz' }
|
|
|
|
|
|
|
|
subject { described_class.new(app, env) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
provider.stub_chain(:state, :id).and_return(:stopped)
|
|
|
|
subject.call(env)
|
|
|
|
end
|
|
|
|
|
2013-04-05 05:23:30 +00:00
|
|
|
it "asks the driver to compress container's rootfs" do
|
2014-03-14 14:37:50 +00:00
|
|
|
expect(driver).to have_received(:compress_rootfs)
|
2013-03-30 22:18:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets export.temp_dir on action env' do
|
2014-03-14 14:37:50 +00:00
|
|
|
expect(env['package.rootfs']).to eq(compressed_rootfs_path)
|
2013-03-30 22:18:05 +00:00
|
|
|
end
|
|
|
|
end
|