diff options
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/backup/database_spec.rb | 21 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/artifact_file_reader_spec.rb | 11 |
2 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/backup/database_spec.rb b/spec/lib/backup/database_spec.rb index fccd6db0018..2bce4cab679 100644 --- a/spec/lib/backup/database_spec.rb +++ b/spec/lib/backup/database_spec.rb @@ -48,5 +48,26 @@ RSpec.describe Backup::Database do expect(output).to include(visible_error) end end + + context 'with PostgreSQL settings defined in the environment' do + let(:cmd) { %W[#{Gem.ruby} -e] + ["$stderr.puts ENV.to_h.select { |k, _| k.start_with?('PG') }"] } + let(:config) { YAML.load_file(File.join(Rails.root, 'config', 'database.yml'))['test'] } + + before do + stub_const 'ENV', ENV.to_h.merge({ + 'GITLAB_BACKUP_PGHOST' => 'test.example.com', + 'PGPASSWORD' => 'donotchange' + }) + end + + it 'overrides default config values' do + subject.restore + + expect(output).to include(%("PGHOST"=>"test.example.com")) + expect(output).to include(%("PGPASSWORD"=>"donotchange")) + expect(output).to include(%("PGPORT"=>"#{config['port']}")) if config['port'] + expect(output).to include(%("PGUSER"=>"#{config['username']}")) if config['username'] + end + end end end diff --git a/spec/lib/gitlab/ci/artifact_file_reader_spec.rb b/spec/lib/gitlab/ci/artifact_file_reader_spec.rb index e982f0eb015..83a37655ea9 100644 --- a/spec/lib/gitlab/ci/artifact_file_reader_spec.rb +++ b/spec/lib/gitlab/ci/artifact_file_reader_spec.rb @@ -18,6 +18,17 @@ RSpec.describe Gitlab::Ci::ArtifactFileReader do expect(YAML.safe_load(subject).keys).to contain_exactly('rspec', 'time', 'custom') end + context 'when FF ci_new_artifact_file_reader is disabled' do + before do + stub_feature_flags(ci_new_artifact_file_reader: false) + end + + it 'returns the content at the path' do + is_expected.to be_present + expect(YAML.safe_load(subject).keys).to contain_exactly('rspec', 'time', 'custom') + end + end + context 'when path does not exist' do let(:path) { 'file/does/not/exist.txt' } let(:expected_error) do |