2013-03-02 12:17:04 -03:00
|
|
|
require 'unit_helper'
|
|
|
|
|
2013-03-03 02:24:05 -03:00
|
|
|
require 'vagrant-lxc/action/base_action'
|
2013-03-02 12:17:04 -03:00
|
|
|
require 'vagrant-lxc/action/handle_box_metadata'
|
|
|
|
|
|
|
|
describe Vagrant::LXC::Action::HandleBoxMetadata do
|
2013-03-07 02:09:09 -03:00
|
|
|
let(:metadata) { {'template-opts' => {'--foo' => 'bar'}} }
|
|
|
|
let(:box) { mock(:box, name: 'box-name', metadata: metadata, directory: Pathname.new('/path/to/box')) }
|
2013-03-02 12:17:04 -03:00
|
|
|
let(:machine) { mock(:machine, box: box) }
|
|
|
|
let(:app) { mock(:app, call: true) }
|
|
|
|
let(:env) { {machine: machine} }
|
|
|
|
|
|
|
|
subject { described_class.new(app, env) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
subject.stub(:system)
|
|
|
|
subject.call(env)
|
|
|
|
end
|
|
|
|
|
2013-03-02 23:12:26 -03:00
|
|
|
it 'sets box directory as lxc-cache-path' do
|
|
|
|
metadata['lxc-cache-path'].should == box.directory.to_s
|
2013-03-02 12:17:04 -03:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'prepends vagrant and box name to template-name' do
|
2013-03-07 02:09:09 -03:00
|
|
|
metadata['template-name'].should == "vagrant-#{box.name}"
|
2013-03-02 12:17:04 -03:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'copies box template file to the right folder' do
|
2013-03-07 02:09:09 -03:00
|
|
|
src = box.directory.join('lxc-template').to_s
|
2013-03-02 12:17:04 -03:00
|
|
|
dest = "/usr/share/lxc/templates/lxc-#{metadata['template-name']}"
|
|
|
|
subject.should have_received(:system).with("sudo su root -c \"cp #{src} #{dest}\"")
|
|
|
|
end
|
2013-03-07 02:09:09 -03:00
|
|
|
|
|
|
|
pending 'extracts rootfs'
|
2013-03-02 12:17:04 -03:00
|
|
|
end
|