core: Fix Downloader tests
This commit is contained in:
parent
c31feb0e94
commit
05eeefbe36
|
@ -40,6 +40,7 @@ module Vagrant
|
||||||
def download!
|
def download!
|
||||||
options, subprocess_options = self.options
|
options, subprocess_options = self.options
|
||||||
options += ["--output", @destination]
|
options += ["--output", @destination]
|
||||||
|
options << @source
|
||||||
|
|
||||||
# This variable can contain the proc that'll be sent to
|
# This variable can contain the proc that'll be sent to
|
||||||
# the subprocess execute.
|
# the subprocess execute.
|
||||||
|
@ -122,6 +123,7 @@ module Vagrant
|
||||||
def head
|
def head
|
||||||
options, subprocess_options = self.options
|
options, subprocess_options = self.options
|
||||||
options.unshift("-I")
|
options.unshift("-I")
|
||||||
|
options << @source
|
||||||
|
|
||||||
@logger.info("HEAD: #{@source}")
|
@logger.info("HEAD: #{@source}")
|
||||||
result = execute_curl(options, subprocess_options)
|
result = execute_curl(options, subprocess_options)
|
||||||
|
@ -177,7 +179,6 @@ module Vagrant
|
||||||
options += ["--continue-at", "-"] if @continue
|
options += ["--continue-at", "-"] if @continue
|
||||||
options << "--insecure" if @insecure
|
options << "--insecure" if @insecure
|
||||||
options << "--cert" << @client_cert if @client_cert
|
options << "--cert" << @client_cert if @client_cert
|
||||||
options << @source
|
|
||||||
|
|
||||||
# Specify some options for the subprocess
|
# Specify some options for the subprocess
|
||||||
subprocess_options = {}
|
subprocess_options = {}
|
||||||
|
|
|
@ -54,4 +54,22 @@ describe Vagrant::Util::Downloader do
|
||||||
pending "tests for a UI"
|
pending "tests for a UI"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#head" do
|
||||||
|
let(:curl_options) {
|
||||||
|
["--fail", "--location", "--max-redirs", "10", "--user-agent", described_class::USER_AGENT, source, {}]
|
||||||
|
}
|
||||||
|
|
||||||
|
it "returns the output" do
|
||||||
|
subprocess_result.stub(stdout: "foo")
|
||||||
|
|
||||||
|
options = curl_options.dup
|
||||||
|
options.unshift("-I")
|
||||||
|
|
||||||
|
Vagrant::Util::Subprocess.should_receive(:execute).
|
||||||
|
with("curl", *options).and_return(subprocess_result)
|
||||||
|
|
||||||
|
expect(subject.head).to eq("foo")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue