(#9085) - Add test for converting windows paths

This commit adds a test for checking that a windows path for mounting a
volume in a container is properly converted into something that's
usable.
This commit is contained in:
Brian Cain 2018-08-08 10:30:04 -07:00
parent 03178bbe04
commit 5d2d784ae7
No known key found for this signature in database
GPG Key ID: 43D51080D357A001
2 changed files with 34 additions and 7 deletions

View File

@ -57,12 +57,12 @@ module VagrantPlugins
v = [host, guest].join(":") v = [host, guest].join(":")
else else
host, guest = v.split(":", 2) host, guest = v.split(":", 2)
host = Vagrant::Util::Platform.windows_path(host) host = Vagrant::Util::Platform.windows_path(host)
# NOTE: Docker does not support UNC style paths (which also # NOTE: Docker does not support UNC style paths (which also
# means that there's no long path support). Hopefully this # means that there's no long path support). Hopefully this
# will be fixed someday and the gsub below can be removed. # will be fixed someday and the gsub below can be removed.
host.gsub!(/^[^A-Za-z]+/, "") host.gsub!(/^[^A-Za-z]+/, "")
v = [host, guest].join(":") v = [host, guest].join(":")
end end
end end

View File

@ -65,6 +65,33 @@ describe VagrantPlugins::DockerProvider::Driver do
end end
end end
describe '#create windows' do
let(:params) { {
image: 'jimi/hendrix:eletric-ladyland',
cmd: ['play', 'voodoo-chile'],
ports: '8080:80',
volumes: 'C:/Users/BobDylan/AllAlong:/The/Watchtower',
detach: true,
links: [[:janis, 'joplin'], [:janis, 'janis']],
env: {key: 'value'},
name: cid,
hostname: 'jimi-hendrix',
privileged: true
} }
let(:translated_path) { "//c/Users/BobDylan/AllAlong:/The/Watchtower" }
before do
allow(Vagrant::Util::Platform).to receive(:windows?).and_return(true)
subject.create(params)
end
it 'shares folders' do
expect(cmd_executed).to match(/-v #{translated_path} .+ #{Regexp.escape params[:image]}/)
end
end
describe '#created?' do describe '#created?' do
let(:result) { subject.created?(cid) } let(:result) { subject.created?(cid) }