Commit 53d1c87c authored by Kamil Trzciński's avatar Kamil Trzciński

Fix Fog mocking

parent 3201988b
require 'spec_helper'
describe 'Fog::Storage::GoogleXML::File' do
describe 'Fog::Storage::GoogleXML::File', :fog_requests do
let(:storage) do
Fog.mock!
Fog::Storage.new({
Fog::Storage.new(
google_storage_access_key_id: "asdf",
google_storage_secret_access_key: "asdf",
provider: "Google"
})
)
end
let(:file) do
......
......@@ -274,16 +274,13 @@ describe Backup::Manager do
}
)
# the Fog mock only knows about directories we create explicitly
Fog.mock!
# the Fog mock only knows about directories we create explicitly
connection = ::Fog::Storage.new(Gitlab.config.backup.upload.connection.symbolize_keys)
connection.directories.create(key: Gitlab.config.backup.upload.remote_directory)
end
after do
Fog.unmock!
end
context 'target path' do
it 'uses the tar filename by default' do
expect_any_instance_of(Fog::Collection).to receive(:create)
......
......@@ -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) }
before do
Fog.unmock!
end
describe '#has_length' do
context 'is known' do
let(:has_length) { true }
......
......@@ -133,6 +133,10 @@ RSpec.configure do |config|
RequestStore.clear!
end
config.after(:example) do
Fog.unmock! if Fog.mock?
end
config.before(:example, :mailer) do
reset_delivered_emails!
end
......
......@@ -360,13 +360,6 @@ describe ObjectStorage do
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
it "returns temporary path" do
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