2013-03-02 15:17:04 +00:00
|
|
|
require 'unit_helper'
|
|
|
|
|
2013-04-05 06:10:38 +00:00
|
|
|
require 'vagrant'
|
2013-03-02 15:17:04 +00:00
|
|
|
require 'vagrant-lxc/action/handle_box_metadata'
|
|
|
|
|
|
|
|
describe Vagrant::LXC::Action::HandleBoxMetadata do
|
|
|
|
let(:app) { mock(:app, call: true) }
|
2013-03-11 03:13:48 +00:00
|
|
|
let(:env) { {machine: machine, ui: stub(info: true)} }
|
2013-04-05 06:10:38 +00:00
|
|
|
let(:machine) { mock(:machine, box: box) }
|
|
|
|
let(:box) { mock(:box, name: 'box-name', metadata: metadata, directory: box_directory) }
|
|
|
|
let(:box_directory) { Pathname.new('/path/to/box') }
|
|
|
|
let(:metadata) { {'template-opts' => {'--foo' => 'bar'}} }
|
|
|
|
let(:vagrant_key) { Vagrant.source_root.join('keys', 'vagrant.pub').expand_path.to_s }
|
2013-03-02 15:17:04 +00:00
|
|
|
|
|
|
|
subject { described_class.new(app, env) }
|
|
|
|
|
|
|
|
before do
|
2013-03-08 03:54:15 +00:00
|
|
|
File.stub(exists?: true)
|
2013-03-02 15:17:04 +00:00
|
|
|
subject.call(env)
|
|
|
|
end
|
|
|
|
|
2013-04-05 06:10:38 +00:00
|
|
|
it 'sets the tarball argument for the template' do
|
|
|
|
env[:lxc_template_opts].should include(
|
|
|
|
'--tarball' => box_directory.join('rootfs.tar.gz').to_s
|
|
|
|
)
|
2013-03-02 15:17:04 +00:00
|
|
|
end
|
|
|
|
|
2013-04-05 06:10:38 +00:00
|
|
|
it 'sets the auth key argument for the template' do
|
|
|
|
env[:lxc_template_opts].should include(
|
|
|
|
'--auth-key' => vagrant_key
|
|
|
|
)
|
2013-03-02 15:17:04 +00:00
|
|
|
end
|
|
|
|
|
2013-04-05 06:10:38 +00:00
|
|
|
it 'sets the template options from metadata on env hash' do
|
|
|
|
env[:lxc_template_opts].should include(metadata['template-opts'])
|
|
|
|
end
|
2013-03-08 03:54:15 +00:00
|
|
|
|
2013-04-05 06:10:38 +00:00
|
|
|
it 'sets the template source path on env hash' do
|
|
|
|
env[:lxc_template_src].should == box_directory.join('lxc-template').to_s
|
2013-03-02 15:17:04 +00:00
|
|
|
end
|
|
|
|
end
|