Commit 9c729fca authored by Michael Kozono's avatar Michael Kozono

Get LfsTransfer spec working

parent a74d97d3
require 'spec_helper'
describe Gitlab::Geo::Transfer do
describe Gitlab::Geo::LfsTransfer do
include ::EE::GeoHelpers
set(:primary_node) { create(:geo_node, :primary) }
set(:secondary_node) { create(:geo_node) }
set(:lfs_object) { create(:lfs_object, :with_file) }
let(:lfs_object_file_path) { lfs_object.file.path }
let(:url) { primary_node.geo_transfers_url(:lfs, lfs_object.id.to_s) }
let(:content) { SecureRandom.random_bytes(10) }
let(:size) { File.stat(lfs_object.file.path).size }
subject do
described_class.new(:lfs,
lfs_object.id,
lfs_object_file_path,
{ sha256: lfs_object.oid })
described_class.new(lfs_object)
end
context '#download_from_primary' do
......@@ -25,9 +21,9 @@ describe Gitlab::Geo::Transfer do
context 'when the destination filename is a directory' do
it 'returns a failed result' do
transfer = described_class.new(:lfs, lfs_object.id, '/tmp', { sha256: lfs_object.id })
expect(lfs_object).to receive(:file).and_return(double(path: '/tmp'))
result = transfer.download_from_primary
result = subject.download_from_primary
expect_result(result, success: false, bytes_downloaded: 0, primary_missing_file: false)
end
......@@ -88,9 +84,9 @@ describe Gitlab::Geo::Transfer do
end
context "invalid path" do
let(:lfs_object_file_path) { '/foo/bar' }
it 'logs an error if the destination directory could not be created' do
expect(lfs_object).to receive(:file).and_return(double(path: '/foo/bar'))
allow(FileUtils).to receive(:mkdir_p) { raise Errno::EEXIST }
expect(subject).to receive(:log_error).with("unable to create directory /foo: File exists")
......
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