core: Builtin SyncedFolders accepts alternate config

This commit is contained in:
Mitchell Hashimoto 2014-04-16 11:20:09 -07:00
parent 0153e0ccbb
commit 3c9219b8c9
2 changed files with 45 additions and 1 deletions

View File

@ -18,7 +18,7 @@ module Vagrant
end
def call(env)
folders = synced_folders(env[:machine])
folders = synced_folders(env[:machine], env[:synced_folders_config])
folders.each do |impl_name, fs|
@logger.info("Synced Folder Implementation: #{impl_name}")

View File

@ -3,6 +3,8 @@ require "tmpdir"
require File.expand_path("../../../../base", __FILE__)
require Vagrant.source_root.join("plugins/kernel_v2/config/vm")
describe Vagrant::Action::Builtin::SyncedFolders do
include_context "unit"
include_context "synced folder actions"
@ -96,5 +98,47 @@ describe Vagrant::Action::Builtin::SyncedFolders do
expect(ids.length).to eq(2)
expect(ids[0]).to eq(ids[1])
end
it "syncs custom folders" do
ids = []
order = []
tracker = Class.new(impl(true, "good")) do
define_method(:prepare) do |machine, folders, opts|
ids << self.object_id
order << :prepare
end
define_method(:enable) do |machine, folders, opts|
ids << self.object_id
order << :enable
end
end
plugins[:tracker] = [tracker, 15]
synced_folders["tracker"] = {
"root" => {
hostpath: "foo",
},
"other" => {
hostpath: "bar",
create: true,
}
}
new_config = double("config")
env[:synced_folders_config] = new_config
expect(subject).to receive(:synced_folders).
with(machine, new_config).
and_return(synced_folders)
subject.call(env)
expect(order).to eq([:prepare, :enable])
expect(ids.length).to eq(2)
expect(ids[0]).to eq(ids[1])
end
end
end