Commit 0a5f3aa3 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-fog-mocking' into 'master'

Fix Fog mocking

Closes #47300

See merge request gitlab-org/gitlab-ce!19425
parents 6153a616 53d1c87c
require 'spec_helper' require 'spec_helper'
describe 'Fog::Storage::GoogleXML::File' do describe 'Fog::Storage::GoogleXML::File', :fog_requests do
let(:storage) do let(:storage) do
Fog.mock! Fog.mock!
Fog::Storage.new({ Fog::Storage.new(
google_storage_access_key_id: "asdf", google_storage_access_key_id: "asdf",
google_storage_secret_access_key: "asdf", google_storage_secret_access_key: "asdf",
provider: "Google" provider: "Google"
}) )
end end
let(:file) do let(:file) do
......
...@@ -274,16 +274,13 @@ describe Backup::Manager do ...@@ -274,16 +274,13 @@ describe Backup::Manager do
} }
) )
# the Fog mock only knows about directories we create explicitly
Fog.mock! Fog.mock!
# the Fog mock only knows about directories we create explicitly
connection = ::Fog::Storage.new(Gitlab.config.backup.upload.connection.symbolize_keys) connection = ::Fog::Storage.new(Gitlab.config.backup.upload.connection.symbolize_keys)
connection.directories.create(key: Gitlab.config.backup.upload.remote_directory) connection.directories.create(key: Gitlab.config.backup.upload.remote_directory)
end end
after do
Fog.unmock!
end
context 'target path' do context 'target path' do
it 'uses the tar filename by default' do it 'uses the tar filename by default' do
expect_any_instance_of(Fog::Collection).to receive(:create) expect_any_instance_of(Fog::Collection).to receive(:create)
......
...@@ -17,6 +17,10 @@ describe ObjectStorage::DirectUpload do ...@@ -17,6 +17,10 @@ describe ObjectStorage::DirectUpload do
let(:direct_upload) { described_class.new(credentials, bucket_name, object_name, has_length: has_length, maximum_size: maximum_size) } let(:direct_upload) { described_class.new(credentials, bucket_name, object_name, has_length: has_length, maximum_size: maximum_size) }
before do
Fog.unmock!
end
describe '#has_length' do describe '#has_length' do
context 'is known' do context 'is known' do
let(:has_length) { true } let(:has_length) { true }
......
...@@ -133,6 +133,10 @@ RSpec.configure do |config| ...@@ -133,6 +133,10 @@ RSpec.configure do |config|
RequestStore.clear! RequestStore.clear!
end end
config.after(:example) do
Fog.unmock! if Fog.mock?
end
config.before(:example, :mailer) do config.before(:example, :mailer) do
reset_delivered_emails! reset_delivered_emails!
end end
......
...@@ -360,13 +360,6 @@ describe ObjectStorage do ...@@ -360,13 +360,6 @@ describe ObjectStorage do
subject { uploader_class.workhorse_authorize(has_length: has_length, maximum_size: maximum_size) } subject { uploader_class.workhorse_authorize(has_length: has_length, maximum_size: maximum_size) }
before do
# ensure that we use regular Fog libraries
# other tests might call `Fog.mock!` and
# it will make tests to fail
Fog.unmock!
end
shared_examples 'uses local storage' do shared_examples 'uses local storage' do
it "returns temporary path" do it "returns temporary path" do
is_expected.to have_key(:TempPath) is_expected.to have_key(:TempPath)
......
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