vaguerent/test/unit/vagrant/util/platform_test.rb
Chris Roberts a8b2f78f59 Do not prefix Windows paths if UNC prefix already exists
While VirtualBox has commented that they do not support UNC remote
paths (but do for long paths) it seems that remote paths can work.
If user provides UNC path, allow it to be used as-is.

Fixes #7011
2017-04-20 16:33:38 -07:00

68 lines
1.6 KiB
Ruby

require File.expand_path("../../../base", __FILE__)
require "vagrant/util/platform"
describe Vagrant::Util::Platform do
include_context "unit"
subject { described_class }
describe "#cygwin?" do
before do
allow(subject).to receive(:platform).and_return("test")
described_class.reset!
end
after do
described_class.reset!
end
around do |example|
with_temp_env(VAGRANT_DETECTED_OS: "nope", PATH: "") do
example.run
end
end
it "returns true if VAGRANT_DETECTED_OS includes cygwin" do
with_temp_env(VAGRANT_DETECTED_OS: "cygwin") do
expect(subject).to be_cygwin
end
end
it "returns true if platform has cygwin" do
allow(subject).to receive(:platform).and_return("cygwin")
expect(subject).to be_cygwin
end
it "returns true if the PATH contains cygwin" do
with_temp_env(PATH: "C:/cygwin") do
expect(subject).to be_cygwin
end
end
it "returns false if nothing is available" do
expect(subject).to_not be_cygwin
end
end
describe "#fs_real_path" do
it "fixes drive letters on Windows", :windows do
expect(described_class.fs_real_path("c:/foo").to_s).to eql("C:/foo")
end
end
describe "#windows_unc_path" do
it "correctly converts a path" do
expect(described_class.windows_unc_path("c:/foo").to_s).to eql("\\\\?\\c:\\foo")
end
context "when given a UNC path" do
let(:unc_path){ "\\\\srvname\\path" }
it "should not modify the path" do
expect(described_class.windows_unc_path(unc_path).to_s).to eql(unc_path)
end
end
end
end