Merge pull request #15460 from reitermarkus/fix-curl-test
Fix failing test.
This commit is contained in:
		
						commit
						08cffe0a64
					
				@ -10,9 +10,16 @@ describe CurlDownloadStrategy do
 | 
			
		||||
  let(:version) { "1.2.3" }
 | 
			
		||||
  let(:specs) { { user: "download:123456" } }
 | 
			
		||||
  let(:artifact_domain) { nil }
 | 
			
		||||
  let(:headers) do
 | 
			
		||||
    {
 | 
			
		||||
      "accept-ranges"  => "bytes",
 | 
			
		||||
      "content-length" => "37182",
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  before do
 | 
			
		||||
    allow(strategy).to receive(:curl_headers).and_return({ responses: [{ headers: {} }] })
 | 
			
		||||
    allow(strategy).to receive(:curl_headers).with(any_args)
 | 
			
		||||
                                             .and_return({ responses: [{ headers: headers }] })
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it "parses the opts and sets the corresponding args" do
 | 
			
		||||
 | 
			
		||||
@ -174,21 +174,20 @@ module Utils
 | 
			
		||||
      destination.dirname.mkpath
 | 
			
		||||
 | 
			
		||||
      if try_partial
 | 
			
		||||
        range_stdout = curl_output("--location", "--head", *args, **options).stdout
 | 
			
		||||
        parsed_output = parse_curl_output(range_stdout)
 | 
			
		||||
 | 
			
		||||
        headers = if parsed_output[:responses].present?
 | 
			
		||||
          parsed_output[:responses].last[:headers]
 | 
			
		||||
        else
 | 
			
		||||
          {}
 | 
			
		||||
        headers = begin
 | 
			
		||||
          parsed_output = curl_headers(*args, **options, wanted_headers: ["accept-ranges"])
 | 
			
		||||
          parsed_output.fetch(:responses).last&.fetch(:headers)
 | 
			
		||||
        rescue ErrorDuringExecution
 | 
			
		||||
          nil
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        # Any value for `accept-ranges` other than none indicates that the server supports partial requests.
 | 
			
		||||
        # Its absence indicates no support.
 | 
			
		||||
        supports_partial = headers.key?("accept-ranges") && headers["accept-ranges"] != "none"
 | 
			
		||||
        supports_partial = headers&.key?("accept-ranges") && headers["accept-ranges"] != "none"
 | 
			
		||||
 | 
			
		||||
        if supports_partial &&
 | 
			
		||||
           destination.exist? &&
 | 
			
		||||
           headers&.key?("content-length") &&
 | 
			
		||||
           destination.size == headers["content-length"].to_i
 | 
			
		||||
          return # We've already downloaded all the bytes
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user