diff options
Diffstat (limited to 'spec/config/object_store_settings_spec.rb')
-rw-r--r-- | spec/config/object_store_settings_spec.rb | 87 |
1 files changed, 78 insertions, 9 deletions
diff --git a/spec/config/object_store_settings_spec.rb b/spec/config/object_store_settings_spec.rb index 33443509e4a..56ad0943377 100644 --- a/spec/config/object_store_settings_spec.rb +++ b/spec/config/object_store_settings_spec.rb @@ -162,14 +162,14 @@ RSpec.describe ObjectStoreSettings do { 'enabled' => true, 'remote_directory' => 'some-bucket', - 'direct_upload' => true, - 'background_upload' => false, + 'direct_upload' => false, + 'background_upload' => true, 'proxy_download' => false } end before do - settings.lfs['object_store'] = described_class.legacy_parse(legacy_settings) + settings.lfs['object_store'] = described_class.legacy_parse(legacy_settings, 'lfs') end it 'does not alter config if legacy settings are specified' do @@ -177,6 +177,35 @@ RSpec.describe ObjectStoreSettings do expect(settings.artifacts['object_store']).to be_nil expect(settings.lfs['object_store']['remote_directory']).to eq('some-bucket') + # Disable background_upload, regardless of the input config + expect(settings.lfs['object_store']['direct_upload']).to eq(true) + expect(settings.lfs['object_store']['background_upload']).to eq(false) + expect(settings.external_diffs['object_store']).to be_nil + end + end + + context 'with legacy config and legacy background upload is enabled' do + let(:legacy_settings) do + { + 'enabled' => true, + 'remote_directory' => 'some-bucket', + 'proxy_download' => false + } + end + + before do + stub_env(ObjectStoreSettings::LEGACY_BACKGROUND_UPLOADS_ENV, 'lfs') + settings.lfs['object_store'] = described_class.legacy_parse(legacy_settings, 'lfs') + end + + it 'enables background_upload and disables direct_upload' do + subject + + expect(settings.artifacts['object_store']).to be_nil + expect(settings.lfs['object_store']['remote_directory']).to eq('some-bucket') + # Enable background_upload if the environment variable is available + expect(settings.lfs['object_store']['direct_upload']).to eq(false) + expect(settings.lfs['object_store']['background_upload']).to eq(true) expect(settings.external_diffs['object_store']).to be_nil end end @@ -185,11 +214,11 @@ RSpec.describe ObjectStoreSettings do describe '.legacy_parse' do it 'sets correct default values' do - settings = described_class.legacy_parse(nil) + settings = described_class.legacy_parse(nil, 'artifacts') expect(settings['enabled']).to be false - expect(settings['direct_upload']).to be false - expect(settings['background_upload']).to be true + expect(settings['direct_upload']).to be true + expect(settings['background_upload']).to be false expect(settings['remote_directory']).to be nil end @@ -199,12 +228,52 @@ RSpec.describe ObjectStoreSettings do 'remote_directory' => 'artifacts' }) - settings = described_class.legacy_parse(original_settings) + settings = described_class.legacy_parse(original_settings, 'artifacts') expect(settings['enabled']).to be true - expect(settings['direct_upload']).to be false - expect(settings['background_upload']).to be true + expect(settings['direct_upload']).to be true + expect(settings['background_upload']).to be false expect(settings['remote_directory']).to eq 'artifacts' end + + context 'legacy background upload environment variable is enabled' do + before do + stub_env(ObjectStoreSettings::LEGACY_BACKGROUND_UPLOADS_ENV, 'artifacts,lfs') + end + + it 'enables background_upload and disables direct_upload' do + original_settings = Settingslogic.new({ + 'enabled' => true, + 'remote_directory' => 'artifacts' + }) + + settings = described_class.legacy_parse(original_settings, 'artifacts') + + expect(settings['enabled']).to be true + expect(settings['direct_upload']).to be false + expect(settings['background_upload']).to be true + expect(settings['remote_directory']).to eq 'artifacts' + end + end + + context 'legacy background upload environment variable is enabled for other types' do + before do + stub_env(ObjectStoreSettings::LEGACY_BACKGROUND_UPLOADS_ENV, 'uploads,lfs') + end + + it 'enables direct_upload and disables background_upload' do + original_settings = Settingslogic.new({ + 'enabled' => true, + 'remote_directory' => 'artifacts' + }) + + settings = described_class.legacy_parse(original_settings, 'artifacts') + + expect(settings['enabled']).to be true + expect(settings['direct_upload']).to be true + expect(settings['background_upload']).to be false + expect(settings['remote_directory']).to eq 'artifacts' + end + end end end |