diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/lib/system_check | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/lib/system_check')
3 files changed, 123 insertions, 65 deletions
diff --git a/spec/lib/system_check/app/hashed_storage_all_projects_check_spec.rb b/spec/lib/system_check/app/hashed_storage_all_projects_check_spec.rb new file mode 100644 index 00000000000..e5e7f6a4450 --- /dev/null +++ b/spec/lib/system_check/app/hashed_storage_all_projects_check_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'rake_helper' + +describe SystemCheck::App::HashedStorageAllProjectsCheck do + before do + silence_output + end + + describe '#check?' do + it 'fails when at least one project is in legacy storage' do + create(:project, :legacy_storage) + + expect(subject.check?).to be_falsey + end + + it 'succeeds when all projects are in hashed storage' do + create(:project) + + expect(subject.check?).to be_truthy + end + end +end diff --git a/spec/lib/system_check/app/hashed_storage_enabled_check_spec.rb b/spec/lib/system_check/app/hashed_storage_enabled_check_spec.rb new file mode 100644 index 00000000000..d5a0014b791 --- /dev/null +++ b/spec/lib/system_check/app/hashed_storage_enabled_check_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'rake_helper' + +describe SystemCheck::App::HashedStorageEnabledCheck do + before do + silence_output + end + + describe '#check?' do + it 'fails when hashed storage is disabled' do + stub_application_setting(hashed_storage_enabled: false) + + expect(subject.check?).to be_falsey + end + + it 'succeeds when hashed storage is enabled' do + stub_application_setting(hashed_storage_enabled: true) + + expect(subject.check?).to be_truthy + end + end +end diff --git a/spec/lib/system_check/simple_executor_spec.rb b/spec/lib/system_check/simple_executor_spec.rb index 94094343ec6..58f3a7df197 100644 --- a/spec/lib/system_check/simple_executor_spec.rb +++ b/spec/lib/system_check/simple_executor_spec.rb @@ -4,99 +4,109 @@ require 'spec_helper' require 'rake_helper' describe SystemCheck::SimpleExecutor do - class SimpleCheck < SystemCheck::BaseCheck - set_name 'my simple check' - - def check? - true + before do + stub_const('SimpleCheck', Class.new(SystemCheck::BaseCheck)) + stub_const('OtherCheck', Class.new(SystemCheck::BaseCheck)) + stub_const('SkipCheck', Class.new(SystemCheck::BaseCheck)) + stub_const('DynamicSkipCheck', Class.new(SystemCheck::BaseCheck)) + stub_const('MultiCheck', Class.new(SystemCheck::BaseCheck)) + stub_const('SkipMultiCheck', Class.new(SystemCheck::BaseCheck)) + stub_const('RepairCheck', Class.new(SystemCheck::BaseCheck)) + stub_const('BugousCheck', Class.new(SystemCheck::BaseCheck)) + + SimpleCheck.class_eval do + set_name 'my simple check' + + def check? + true + end end - end - class OtherCheck < SystemCheck::BaseCheck - set_name 'other check' + OtherCheck.class_eval do + set_name 'other check' - def check? - false - end + def check? + false + end - def show_error - $stdout.puts 'this is an error text' + def show_error + $stdout.puts 'this is an error text' + end end - end - class SkipCheck < SystemCheck::BaseCheck - set_name 'skip check' - set_skip_reason 'this is a skip reason' + SkipCheck.class_eval do + set_name 'skip check' + set_skip_reason 'this is a skip reason' - def skip? - true - end + def skip? + true + end - def check? - raise 'should not execute this' + def check? + raise 'should not execute this' + end end - end - class DynamicSkipCheck < SystemCheck::BaseCheck - set_name 'dynamic skip check' - set_skip_reason 'this is a skip reason' + DynamicSkipCheck.class_eval do + set_name 'dynamic skip check' + set_skip_reason 'this is a skip reason' - def skip? - self.skip_reason = 'this is a dynamic skip reason' - true - end + def skip? + self.skip_reason = 'this is a dynamic skip reason' + true + end - def check? - raise 'should not execute this' + def check? + raise 'should not execute this' + end end - end - class MultiCheck < SystemCheck::BaseCheck - set_name 'multi check' + MultiCheck.class_eval do + set_name 'multi check' - def multi_check - $stdout.puts 'this is a multi output check' - end + def multi_check + $stdout.puts 'this is a multi output check' + end - def check? - raise 'should not execute this' + def check? + raise 'should not execute this' + end end - end - class SkipMultiCheck < SystemCheck::BaseCheck - set_name 'skip multi check' + SkipMultiCheck.class_eval do + set_name 'skip multi check' - def skip? - true - end + def skip? + true + end - def multi_check - raise 'should not execute this' + def multi_check + raise 'should not execute this' + end end - end - class RepairCheck < SystemCheck::BaseCheck - set_name 'repair check' + RepairCheck.class_eval do + set_name 'repair check' - def check? - false - end + def check? + false + end - def repair! - true - end + def repair! + true + end - def show_error - $stdout.puts 'this is an error message' + def show_error + $stdout.puts 'this is an error message' + end end - end - class BugousCheck < SystemCheck::BaseCheck - CustomError = Class.new(StandardError) - set_name 'my bugous check' + BugousCheck.class_eval do + set_name 'my bugous check' - def check? - raise CustomError, 'omg' + def check? + raise StandardError, 'omg' + end end end |