synced_folders/rsync: expand host paths relative to root path
This commit is contained in:
parent
309d12a16b
commit
b4b62daf5c
|
@ -9,6 +9,7 @@ module VagrantPlugins
|
||||||
# Folder info
|
# Folder info
|
||||||
guestpath = opts[:guestpath]
|
guestpath = opts[:guestpath]
|
||||||
hostpath = opts[:hostpath]
|
hostpath = opts[:hostpath]
|
||||||
|
hostpath = File.expand_path(hostpath, machine.env.root_path)
|
||||||
|
|
||||||
# Connection information
|
# Connection information
|
||||||
username = ssh_info[:username]
|
username = ssh_info[:username]
|
||||||
|
|
|
@ -27,7 +27,9 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
let(:ssh_info) {{
|
let(:ssh_info) {{
|
||||||
private_key_path: [],
|
private_key_path: [],
|
||||||
}}
|
}}
|
||||||
let(:opts) { {} }
|
let(:opts) {{
|
||||||
|
hostpath: "/foo",
|
||||||
|
}}
|
||||||
let(:ui) { machine.ui }
|
let(:ui) { machine.ui }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -48,6 +50,34 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
to raise_error(Vagrant::Errors::RSyncError)
|
to raise_error(Vagrant::Errors::RSyncError)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "host and guest paths" do
|
||||||
|
it "syncs the hostpath to the guest path" do
|
||||||
|
opts[:hostpath] = "/foo"
|
||||||
|
opts[:guestpath] = "/bar"
|
||||||
|
|
||||||
|
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args|
|
||||||
|
expect(args[args.length - 3]).to eql("/foo")
|
||||||
|
expect(args[args.length - 2]).to include("/bar")
|
||||||
|
end
|
||||||
|
|
||||||
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "expands the hostpath relative to the root path" do
|
||||||
|
opts[:hostpath] = "foo"
|
||||||
|
opts[:guestpath] = "/bar"
|
||||||
|
|
||||||
|
hostpath_expanded = File.expand_path(opts[:hostpath], machine.env.root_path)
|
||||||
|
|
||||||
|
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args|
|
||||||
|
expect(args[args.length - 3]).to eql(hostpath_expanded)
|
||||||
|
expect(args[args.length - 2]).to include("/bar")
|
||||||
|
end
|
||||||
|
|
||||||
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "executes within the root path" do
|
it "executes within the root path" do
|
||||||
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args|
|
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args|
|
||||||
expect(args.last).to be_kind_of(Hash)
|
expect(args.last).to be_kind_of(Hash)
|
||||||
|
|
Loading…
Reference in New Issue