Commit 002819ad authored by Gabriel Mazetto's avatar Gabriel Mazetto

Rename Transfer to BaseTransfer

parent b7c83960
......@@ -3,7 +3,7 @@
module Gitlab
module Geo
module Replication
class Transfer
class BaseTransfer
include LogHelpers
attr_reader :file_type, :file_id, :filename, :expected_checksum, :request_data
......@@ -127,7 +127,7 @@ module Gitlab
end
def code_file_not_found?(geo_code)
geo_code == Gitlab::Geo::FileUploader::FILE_NOT_FOUND_GEO_CODE
geo_code == Gitlab::Geo::Replication::FileUploader::FILE_NOT_FOUND_GEO_CODE
end
def default_permissions
......
......@@ -7,7 +7,7 @@ module Gitlab
# * Requesting an Upload file from the primary
# * Saving it in the right place on successful download
# * Returning a detailed Result object
class FileTransfer < Transfer
class FileTransfer < BaseTransfer
def initialize(file_type, upload)
super(
file_type,
......
......@@ -7,7 +7,7 @@ module Gitlab
# * Requesting an ::Ci::JobArtifact file from the primary
# * Saving it in the right place on successful download
# * Returning a detailed Result object
class JobArtifactTransfer < Transfer
class JobArtifactTransfer < BaseTransfer
def initialize(job_artifact)
super(
:job_artifact,
......
......@@ -7,7 +7,7 @@ module Gitlab
# * Requesting an LfsObject file from the primary
# * Saving it in the right place on successful download
# * Returning a detailed Result object
class LfsTransfer < Transfer
class LfsTransfer < BaseTransfer
def initialize(lfs_object)
super(
:lfs,
......
......@@ -65,6 +65,7 @@ describe Gitlab::Geo::Replication::FileTransfer do
it 'returns a failed result indicating primary_missing_file' do
expect(FileUtils).not_to receive(:mv).with(anything, upload.absolute_path).and_call_original
response = double(:response, success?: false, code: 404, msg: "No such file")
expect(File).to receive(:read).and_return("{\"geo_code\":\"#{Gitlab::Geo::Replication::FileUploader::FILE_NOT_FOUND_GEO_CODE}\"}")
expect(Gitlab::HTTP).to receive(:get).and_return(response)
......@@ -78,6 +79,7 @@ describe Gitlab::Geo::Replication::FileTransfer do
it 'returns a failed result' do
expect(FileUtils).not_to receive(:mv).with(anything, upload.absolute_path).and_call_original
response = double(:response, success?: false, code: 404, msg: 'No such file')
expect(Gitlab::HTTP).to receive(:get).and_return(response)
result = subject.download_from_primary
......
......@@ -7,7 +7,7 @@ describe Gitlab::Geo::Replication::JobArtifactDownloader, :geo do
context 'with job artifact' do
it 'returns a FileDownloader::Result object' do
downloader = described_class.new(:job_artifact, job_artifact.id)
result = Gitlab::Geo::Replication::Transfer::Result.new(success: true, bytes_downloaded: 1)
result = Gitlab::Geo::Replication::BaseTransfer::Result.new(success: true, bytes_downloaded: 1)
allow_any_instance_of(Gitlab::Geo::Replication::JobArtifactTransfer)
.to receive(:download_from_primary).and_return(result)
......
......@@ -7,7 +7,7 @@ describe Gitlab::Geo::Replication::LfsDownloader, :geo do
context 'with LFS object' do
it 'returns a FileDownloader::Result object' do
downloader = described_class.new(:lfs, lfs_object.id)
result = Gitlab::Geo::Replication::Transfer::Result.new(success: true, bytes_downloaded: 1)
result = Gitlab::Geo::Replication::BaseTransfer::Result.new(success: true, bytes_downloaded: 1)
allow_any_instance_of(Gitlab::Geo::Replication::LfsTransfer)
.to receive(:download_from_primary).and_return(result)
......
......@@ -446,6 +446,6 @@ describe Geo::FileDownloadService do
success: success,
primary_missing_file: primary_missing_file)
instance = double("(instance of Gitlab::Geo::Replication::Transfer)", download_from_primary: result)
allow(Gitlab::Geo::Replication::Transfer).to receive(:new).and_return(instance)
allow(Gitlab::Geo::Replication::BaseTransfer).to receive(:new).and_return(instance)
end
end
......@@ -312,7 +312,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw do
stub_const('Geo::Scheduler::SchedulerWorker::DB_RETRIEVE_BATCH_SIZE', 5)
secondary.update!(files_max_capacity: 2)
result_object = double(:result, success: true, bytes_downloaded: 100, primary_missing_file: false)
allow_any_instance_of(::Gitlab::Geo::Replication::Transfer).to receive(:download_from_primary).and_return(result_object)
allow_any_instance_of(::Gitlab::Geo::Replication::BaseTransfer).to receive(:download_from_primary).and_return(result_object)
avatar = fixture_file_upload('spec/fixtures/dk.png')
create_list(:lfs_object, 2, :with_file)
......
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