Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-26 12:10:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-26 12:10:42 +0300
commitdb950c5706cdf47f7ccc2e02a4ffd691432ac5dc (patch)
treefdceeac88d490aae384eecc636964d7f03be9c24 /spec
parent7cd527ffd9cfef1c872faa5377eaccc3df6ef067 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/logger_spec.rb24
-rw-r--r--spec/migrations/20230112141236_schedule_vulnerabilities_feedback_migration2_spec.rb31
-rw-r--r--spec/support/helpers/stub_env.rb18
-rw-r--r--spec/tasks/gitlab/backup_rake_spec.rb2
4 files changed, 54 insertions, 21 deletions
diff --git a/spec/lib/gitlab/logger_spec.rb b/spec/lib/gitlab/logger_spec.rb
index ed22af8355f..9f11f3ac629 100644
--- a/spec/lib/gitlab/logger_spec.rb
+++ b/spec/lib/gitlab/logger_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::Logger do
+RSpec.describe Gitlab::Logger, feature_category: :logging do
describe '.build' do
before do
allow(described_class).to receive(:file_name_noext).and_return('log')
@@ -25,40 +25,28 @@ RSpec.describe Gitlab::Logger do
using RSpec::Parameterized::TableSyntax
where(:env_value, :resulting_level) do
- 0 | described_class::DEBUG
- :debug | described_class::DEBUG
'debug' | described_class::DEBUG
'DEBUG' | described_class::DEBUG
'DeBuG' | described_class::DEBUG
- 1 | described_class::INFO
- :info | described_class::INFO
'info' | described_class::INFO
'INFO' | described_class::INFO
'InFo' | described_class::INFO
- 2 | described_class::WARN
- :warn | described_class::WARN
'warn' | described_class::WARN
'WARN' | described_class::WARN
'WaRn' | described_class::WARN
- 3 | described_class::ERROR
- :error | described_class::ERROR
'error' | described_class::ERROR
'ERROR' | described_class::ERROR
'ErRoR' | described_class::ERROR
- 4 | described_class::FATAL
- :fatal | described_class::FATAL
'fatal' | described_class::FATAL
'FATAL' | described_class::FATAL
'FaTaL' | described_class::FATAL
- 5 | described_class::UNKNOWN
- :unknown | described_class::UNKNOWN
'unknown' | described_class::UNKNOWN
'UNKNOWN' | described_class::UNKNOWN
'UnKnOwN' | described_class::UNKNOWN
end
with_them do
- it 'builds logger if valid log level' do
+ it 'builds logger if valid log level is provided' do
stub_env('GITLAB_LOG_LEVEL', env_value)
expect(subject.level).to eq(resulting_level)
@@ -69,15 +57,15 @@ RSpec.describe Gitlab::Logger do
describe '.log_level' do
context 'if GITLAB_LOG_LEVEL is set' do
before do
- stub_env('GITLAB_LOG_LEVEL', described_class::ERROR)
+ stub_env('GITLAB_LOG_LEVEL', 'error')
end
- it 'returns value of GITLAB_LOG_LEVEL' do
- expect(described_class.log_level).to eq(described_class::ERROR)
+ it 'returns value defined by GITLAB_LOG_LEVEL' do
+ expect(described_class.log_level).to eq('error')
end
it 'ignores fallback' do
- expect(described_class.log_level(fallback: described_class::FATAL)).to eq(described_class::ERROR)
+ expect(described_class.log_level(fallback: described_class::FATAL)).to eq('error')
end
end
diff --git a/spec/migrations/20230112141236_schedule_vulnerabilities_feedback_migration2_spec.rb b/spec/migrations/20230112141236_schedule_vulnerabilities_feedback_migration2_spec.rb
new file mode 100644
index 00000000000..0e0f08fea0e
--- /dev/null
+++ b/spec/migrations/20230112141236_schedule_vulnerabilities_feedback_migration2_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe ScheduleVulnerabilitiesFeedbackMigration2, feature_category: :vulnerability_management do
+ let(:migration) { described_class::MIGRATION }
+
+ describe '#up' do
+ it 'schedules background jobs for each batch of Vulnerabilities::Feedback' do
+ migrate!
+
+ expect(migration).to have_scheduled_batched_migration(
+ table_name: :vulnerability_feedback,
+ column_name: :id,
+ interval: described_class::DELAY_INTERVAL,
+ batch_size: described_class::BATCH_SIZE,
+ max_batch_size: described_class::MAX_BATCH_SIZE
+ )
+ end
+ end
+
+ describe '#down' do
+ it 'deletes all batched migration records' do
+ migrate!
+ schema_migrate_down!
+
+ expect(migration).not_to have_scheduled_batched_migration
+ end
+ end
+end
diff --git a/spec/support/helpers/stub_env.rb b/spec/support/helpers/stub_env.rb
index 5f344f8fb52..afa501d6279 100644
--- a/spec/support/helpers/stub_env.rb
+++ b/spec/support/helpers/stub_env.rb
@@ -2,13 +2,23 @@
# Inspired by https://github.com/ljkbennett/stub_env/blob/master/lib/stub_env/helpers.rb
module StubENV
+ # Stub ENV variables
+ #
+ # You can provide either a key and value as separate params or both in a Hash format
+ #
+ # Keys and values will always be converted to String, to comply with how ENV behaves
+ #
+ # @param key_or_hash [String, Hash<String,String>]
+ # @param value [String]
def stub_env(key_or_hash, value = nil)
init_stub unless env_stubbed?
if key_or_hash.is_a? Hash
- key_or_hash.each { |k, v| add_stubbed_value(k, v) }
+ key_or_hash.each do |key, value|
+ add_stubbed_value(key, ensure_env_type(value))
+ end
else
- add_stubbed_value key_or_hash, value
+ add_stubbed_value key_or_hash, ensure_env_type(value)
end
end
@@ -35,4 +45,8 @@ module StubENV
allow(ENV).to receive(:fetch).and_call_original
add_stubbed_value(STUBBED_KEY, true)
end
+
+ def ensure_env_type(value)
+ value.nil? ? value : value.to_s
+ end
end
diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb
index 4aa6edf4789..c0196c09e3c 100644
--- a/spec/tasks/gitlab/backup_rake_spec.rb
+++ b/spec/tasks/gitlab/backup_rake_spec.rb
@@ -2,7 +2,7 @@
require 'rake_helper'
-RSpec.describe 'gitlab:app namespace rake task', :delete, feature_category: :backup_restore do
+RSpec.describe 'gitlab:backup namespace rake tasks', :delete, feature_category: :backup_restore do
let(:enable_registry) { true }
let(:backup_restore_pid_path) { "#{Rails.application.root}/tmp/backup_restore.pid" }
let(:backup_tasks) { %w[db repo uploads builds artifacts pages lfs terraform_state registry packages] }