Commit 2f6a1e19 authored by Michael Kozono's avatar Michael Kozono

Return `false` instead of `nil`

…if not a 404, or if no body is present, because the result will be saved as `missing_on_primary`, which does not allow NULL.
parent 7d869c8b
......@@ -106,10 +106,13 @@ module Gitlab
body = File.read(temp_file.path) if File.exist?(temp_file.path)
if response.code == 404 && body.present?
json_response = JSON.parse(body)
json_response['geo_code'] == Gitlab::Geo::FileUploader::FILE_NOT_FOUND_GEO_CODE
begin
json_response = JSON.parse(body)
return json_response['geo_code'] == Gitlab::Geo::FileUploader::FILE_NOT_FOUND_GEO_CODE
rescue JSON::ParserError
end
end
rescue JSON::ParserError
false
end
......
......@@ -71,7 +71,7 @@ describe Gitlab::Geo::Transfer do
result = subject.download_from_primary
expect_result(result, success: false, bytes_downloaded: 0)
expect_result(result, success: false, bytes_downloaded: 0, primary_missing_file: false)
end
end
end
......@@ -102,9 +102,13 @@ describe Gitlab::Geo::Transfer do
end
end
def expect_result(result, success:, bytes_downloaded:, primary_missing_file: nil)
def expect_result(result, success:, bytes_downloaded:, primary_missing_file:)
expect(result.success).to eq(success)
expect(result.bytes_downloaded).to eq(bytes_downloaded)
expect(result.primary_missing_file).to eq(primary_missing_file)
# Sanity check to help ensure a valid test
expect(success).not_to be_nil
expect(primary_missing_file).not_to be_nil
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment