diff options
Diffstat (limited to 'spec/lib/system_check')
5 files changed, 127 insertions, 127 deletions
diff --git a/spec/lib/system_check/app/git_user_default_ssh_config_check_spec.rb b/spec/lib/system_check/app/git_user_default_ssh_config_check_spec.rb index a0fb86345f3..5d68bbf5346 100644 --- a/spec/lib/system_check/app/git_user_default_ssh_config_check_spec.rb +++ b/spec/lib/system_check/app/git_user_default_ssh_config_check_spec.rb @@ -1,11 +1,11 @@ -require 'spec_helper' +require "spec_helper" describe SystemCheck::App::GitUserDefaultSSHConfigCheck do - let(:username) { '_this_user_will_not_exist_unless_it_is_stubbed' } + let(:username) { "_this_user_will_not_exist_unless_it_is_stubbed" } let(:base_dir) { Dir.mktmpdir } let(:home_dir) { File.join(base_dir, "/var/lib/#{username}") } - let(:ssh_dir) { File.join(home_dir, '.ssh') } - let(:forbidden_file) { 'id_rsa' } + let(:ssh_dir) { File.join(home_dir, ".ssh") } + let(:forbidden_file) { "id_rsa" } before do allow(Gitlab.config.gitlab).to receive(:user).and_return(username) @@ -15,16 +15,16 @@ describe SystemCheck::App::GitUserDefaultSSHConfigCheck do FileUtils.rm_rf(base_dir) end - it 'only whitelists safe files' do + it "only whitelists safe files" do expect(described_class::WHITELIST).to contain_exactly( - 'authorized_keys', - 'authorized_keys2', - 'authorized_keys.lock', - 'known_hosts' + "authorized_keys", + "authorized_keys2", + "authorized_keys.lock", + "known_hosts" ) end - describe '#skip?' do + describe "#skip?" do subject { described_class.new.skip? } where(user_exists: [true, false], home_dir_exists: [true, false]) @@ -41,14 +41,14 @@ describe SystemCheck::App::GitUserDefaultSSHConfigCheck do end end - describe '#check?' do + describe "#check?" do subject { described_class.new.check? } before do stub_user end - it 'fails if a forbidden file exists' do + it "fails if a forbidden file exists" do stub_ssh_file(forbidden_file) is_expected.to be_falsy @@ -60,7 +60,7 @@ describe SystemCheck::App::GitUserDefaultSSHConfigCheck do is_expected.to be_truthy end - it 'succeeds if all the whitelisted files exist' do + it "succeeds if all the whitelisted files exist" do described_class::WHITELIST.each do |filename| stub_ssh_file(filename) end diff --git a/spec/lib/system_check/base_check_spec.rb b/spec/lib/system_check/base_check_spec.rb index faf8c99e772..418ca661ca8 100644 --- a/spec/lib/system_check/base_check_spec.rb +++ b/spec/lib/system_check/base_check_spec.rb @@ -1,14 +1,14 @@ -require 'spec_helper' +require "spec_helper" describe SystemCheck::BaseCheck do - context 'helpers on instance level' do - it 'responds to SystemCheck::Helpers methods' do + context "helpers on instance level" do + it "responds to SystemCheck::Helpers methods" do expect(subject).to respond_to :fix_and_rerun, :for_more_information, :see_installation_guide_section, :finished_checking, :start_checking, :try_fixing_it, :sanitized_message, :should_sanitize?, :omnibus_gitlab?, :sudo_gitlab end - it 'responds to Gitlab::TaskHelpers methods' do + it "responds to Gitlab::TaskHelpers methods" do expect(subject).to respond_to :ask_to_continue, :os_name, :prompt, :run_and_match, :run_command, :run_command!, :uid_for, :gid_for, :gitlab_user, :gitlab_user?, :warn_user_is_not_gitlab, :all_repos, :repository_storage_paths_args, :user_home, :checkout_or_clone_version, :clone_repo, :checkout_version diff --git a/spec/lib/system_check/orphans/namespace_check_spec.rb b/spec/lib/system_check/orphans/namespace_check_spec.rb index 2a61ff3ad65..d8cdd159b72 100644 --- a/spec/lib/system_check/orphans/namespace_check_spec.rb +++ b/spec/lib/system_check/orphans/namespace_check_spec.rb @@ -1,8 +1,8 @@ -require 'spec_helper' -require 'rake_helper' +require "spec_helper" +require "rake_helper" describe SystemCheck::Orphans::NamespaceCheck do - let(:storages) { Gitlab.config.repositories.storages.reject { |key, _| key.eql? 'broken' } } + let(:storages) { Gitlab.config.repositories.storages.reject { |key, _| key.eql? "broken" } } before do allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) @@ -10,44 +10,44 @@ describe SystemCheck::Orphans::NamespaceCheck do silence_output end - describe '#multi_check' do - context 'all orphans' do - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 repos/@hashed) } + describe "#multi_check" do + context "all orphans" do + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 repos/@hashed] } - it 'prints list of all orphaned namespaces except @hashed' do - expect_list_of_orphans(%w(orphan1 orphan2)) + it "prints list of all orphaned namespaces except @hashed" do + expect_list_of_orphans(%w[orphan1 orphan2]) subject.multi_check end end - context 'few orphans with existing namespace' do - let!(:first_level) { create(:group, path: 'my-namespace') } - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed) } + context "few orphans with existing namespace" do + let!(:first_level) { create(:group, path: "my-namespace") } + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed] } - it 'prints list of orphaned namespaces' do - expect_list_of_orphans(%w(orphan1 orphan2)) + it "prints list of orphaned namespaces" do + expect_list_of_orphans(%w[orphan1 orphan2]) subject.multi_check end end - context 'few orphans with existing namespace and parents with same name as orphans' do - let!(:first_level) { create(:group, path: 'my-namespace') } - let!(:second_level) { create(:group, path: 'second-level', parent: first_level) } - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed) } + context "few orphans with existing namespace and parents with same name as orphans" do + let!(:first_level) { create(:group, path: "my-namespace") } + let!(:second_level) { create(:group, path: "second-level", parent: first_level) } + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed] } - it 'prints list of orphaned namespaces ignoring parents with same namespace as orphans' do - expect_list_of_orphans(%w(orphan1 orphan2 second-level)) + it "prints list of orphaned namespaces ignoring parents with same namespace as orphans" do + expect_list_of_orphans(%w[orphan1 orphan2 second-level]) subject.multi_check end end - context 'no orphans' do - let(:disk_namespaces) { %w(@hashed) } + context "no orphans" do + let(:disk_namespaces) { %w[@hashed] } - it 'prints an empty list ignoring @hashed' do + it "prints an empty list ignoring @hashed" do expect_list_of_orphans([]) subject.multi_check @@ -56,6 +56,6 @@ describe SystemCheck::Orphans::NamespaceCheck do end def expect_list_of_orphans(orphans) - expect(subject).to receive(:print_orphans).with(orphans, 'default') + expect(subject).to receive(:print_orphans).with(orphans, "default") end end diff --git a/spec/lib/system_check/orphans/repository_check_spec.rb b/spec/lib/system_check/orphans/repository_check_spec.rb index b0c2267d177..8fc0fa3e77a 100644 --- a/spec/lib/system_check/orphans/repository_check_spec.rb +++ b/spec/lib/system_check/orphans/repository_check_spec.rb @@ -1,8 +1,8 @@ -require 'spec_helper' -require 'rake_helper' +require "spec_helper" +require "rake_helper" describe SystemCheck::Orphans::RepositoryCheck do - let(:storages) { Gitlab.config.repositories.storages.reject { |key, _| key.eql? 'broken' } } + let(:storages) { Gitlab.config.repositories.storages.reject { |key, _| key.eql? "broken" } } before do allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) @@ -11,50 +11,50 @@ describe SystemCheck::Orphans::RepositoryCheck do # silence_output end - describe '#multi_check' do - context 'all orphans' do - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 repos/@hashed) } - let(:disk_repositories) { %w(repo1.git repo2.git) } + describe "#multi_check" do + context "all orphans" do + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 repos/@hashed] } + let(:disk_repositories) { %w[repo1.git repo2.git] } - it 'prints list of all orphaned namespaces except @hashed' do - expect_list_of_orphans(%w(orphan1/repo1.git orphan1/repo2.git orphan2/repo1.git orphan2/repo2.git)) + it "prints list of all orphaned namespaces except @hashed" do + expect_list_of_orphans(%w[orphan1/repo1.git orphan1/repo2.git orphan2/repo1.git orphan2/repo2.git]) subject.multi_check end end - context 'few orphans with existing namespace' do - let!(:first_level) { create(:group, path: 'my-namespace') } - let!(:project) { create(:project, path: 'repo', namespace: first_level) } - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed) } - let(:disk_repositories) { %w(repo.git) } + context "few orphans with existing namespace" do + let!(:first_level) { create(:group, path: "my-namespace") } + let!(:project) { create(:project, path: "repo", namespace: first_level) } + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed] } + let(:disk_repositories) { %w[repo.git] } - it 'prints list of orphaned namespaces' do - expect_list_of_orphans(%w(orphan1/repo.git orphan2/repo.git)) + it "prints list of orphaned namespaces" do + expect_list_of_orphans(%w[orphan1/repo.git orphan2/repo.git]) subject.multi_check end end - context 'few orphans with existing namespace and parents with same name as orphans' do - let!(:first_level) { create(:group, path: 'my-namespace') } - let!(:second_level) { create(:group, path: 'second-level', parent: first_level) } - let!(:project) { create(:project, path: 'repo', namespace: first_level) } - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed) } - let(:disk_repositories) { %w(repo.git) } + context "few orphans with existing namespace and parents with same name as orphans" do + let!(:first_level) { create(:group, path: "my-namespace") } + let!(:second_level) { create(:group, path: "second-level", parent: first_level) } + let!(:project) { create(:project, path: "repo", namespace: first_level) } + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed] } + let(:disk_repositories) { %w[repo.git] } - it 'prints list of orphaned namespaces ignoring parents with same namespace as orphans' do - expect_list_of_orphans(%w(orphan1/repo.git orphan2/repo.git second-level/repo.git)) + it "prints list of orphaned namespaces ignoring parents with same namespace as orphans" do + expect_list_of_orphans(%w[orphan1/repo.git orphan2/repo.git second-level/repo.git]) subject.multi_check end end - context 'no orphans' do - let(:disk_namespaces) { %w(@hashed) } - let(:disk_repositories) { %w(repo.git) } + context "no orphans" do + let(:disk_namespaces) { %w[@hashed] } + let(:disk_repositories) { %w[repo.git] } - it 'prints an empty list ignoring @hashed' do + it "prints an empty list ignoring @hashed" do expect_list_of_orphans([]) subject.multi_check @@ -63,6 +63,6 @@ describe SystemCheck::Orphans::RepositoryCheck do end def expect_list_of_orphans(orphans) - expect(subject).to receive(:print_orphans).with(orphans, 'default') + expect(subject).to receive(:print_orphans).with(orphans, "default") end end diff --git a/spec/lib/system_check/simple_executor_spec.rb b/spec/lib/system_check/simple_executor_spec.rb index e71e9da369d..c8c4f7b76db 100644 --- a/spec/lib/system_check/simple_executor_spec.rb +++ b/spec/lib/system_check/simple_executor_spec.rb @@ -1,9 +1,9 @@ -require 'spec_helper' -require 'rake_helper' +require "spec_helper" +require "rake_helper" describe SystemCheck::SimpleExecutor do class SimpleCheck < SystemCheck::BaseCheck - set_name 'my simple check' + set_name "my simple check" def check? true @@ -11,70 +11,70 @@ describe SystemCheck::SimpleExecutor do end class OtherCheck < SystemCheck::BaseCheck - set_name 'other check' + set_name "other check" def check? false end def show_error - $stdout.puts 'this is an error text' + $stdout.puts "this is an error text" end end class SkipCheck < SystemCheck::BaseCheck - set_name 'skip check' - set_skip_reason 'this is a skip reason' + set_name "skip check" + set_skip_reason "this is a skip reason" def skip? true end def check? - raise 'should not execute this' + raise "should not execute this" end end class DynamicSkipCheck < SystemCheck::BaseCheck - set_name 'dynamic skip check' - set_skip_reason 'this is a skip reason' + set_name "dynamic skip check" + set_skip_reason "this is a skip reason" def skip? - self.skip_reason = 'this is a dynamic skip reason' + self.skip_reason = "this is a dynamic skip reason" true end def check? - raise 'should not execute this' + raise "should not execute this" end end class MultiCheck < SystemCheck::BaseCheck - set_name 'multi check' + set_name "multi check" def multi_check - $stdout.puts 'this is a multi output check' + $stdout.puts "this is a multi output check" end def check? - raise 'should not execute this' + raise "should not execute this" end end class SkipMultiCheck < SystemCheck::BaseCheck - set_name 'skip multi check' + set_name "skip multi check" def skip? true end def multi_check - raise 'should not execute this' + raise "should not execute this" end end class RepairCheck < SystemCheck::BaseCheck - set_name 'repair check' + set_name "repair check" def check? false @@ -85,41 +85,41 @@ describe SystemCheck::SimpleExecutor do end def show_error - $stdout.puts 'this is an error message' + $stdout.puts "this is an error message" end end class BugousCheck < SystemCheck::BaseCheck CustomError = Class.new(StandardError) - set_name 'my bugous check' + set_name "my bugous check" def check? - raise CustomError, 'omg' + raise CustomError, "omg" end end - describe '#component' do - it 'returns stored component name' do - expect(subject.component).to eq('Test') + describe "#component" do + it "returns stored component name" do + expect(subject.component).to eq("Test") end end - describe '#checks' do + describe "#checks" do before do subject << SimpleCheck end - it 'returns a set of classes' do + it "returns a set of classes" do expect(subject.checks).to include(SimpleCheck) end end - describe '#<<' do + describe "#<<" do before do subject << SimpleCheck end - it 'appends a new check to the Set' do + it "appends a new check to the Set" do subject << OtherCheck stored_checks = subject.checks.to_a @@ -127,20 +127,20 @@ describe SystemCheck::SimpleExecutor do expect(stored_checks.last).to eq(OtherCheck) end - it 'inserts unique itens only' do + it "inserts unique itens only" do subject << SimpleCheck expect(subject.checks.size).to eq(1) end - it 'errors out when passing multiple items' do + it "errors out when passing multiple items" do expect { subject << [SimpleCheck, OtherCheck] }.to raise_error(ArgumentError) end end - subject { described_class.new('Test') } + subject { described_class.new("Test") } - describe '#execute' do + describe "#execute" do before do silence_output @@ -148,7 +148,7 @@ describe SystemCheck::SimpleExecutor do subject << OtherCheck end - it 'runs included checks' do + it "runs included checks" do expect(subject).to receive(:run_check).with(SimpleCheck) expect(subject).to receive(:run_check).with(OtherCheck) @@ -156,39 +156,39 @@ describe SystemCheck::SimpleExecutor do end end - describe '#run_check' do - it 'prints check name' do + describe "#run_check" do + it "prints check name" do expect(SimpleCheck).to receive(:display_name).and_call_original expect { subject.run_check(SimpleCheck) }.to output(/my simple check/).to_stdout end - context 'when check pass' do - it 'prints yes' do + context "when check pass" do + it "prints yes" do expect_any_instance_of(SimpleCheck).to receive(:check?).and_call_original expect { subject.run_check(SimpleCheck) }.to output(/ \.\.\. yes/).to_stdout end end - context 'when check fails' do - it 'prints no' do + context "when check fails" do + it "prints no" do expect_any_instance_of(OtherCheck).to receive(:check?).and_call_original expect { subject.run_check(OtherCheck) }.to output(/ \.\.\. no/).to_stdout end - it 'displays error message from #show_error' do + it "displays error message from #show_error" do expect_any_instance_of(OtherCheck).to receive(:show_error).and_call_original expect { subject.run_check(OtherCheck) }.to output(/this is an error text/).to_stdout end - context 'when check implements #repair!' do - it 'executes #repair!' do + context "when check implements #repair!" do + it "executes #repair!" do expect_any_instance_of(RepairCheck).to receive(:repair!) subject.run_check(RepairCheck) end - context 'when repair succeeds' do - it 'does not execute #show_error' do + context "when repair succeeds" do + it "does not execute #show_error" do expect_any_instance_of(RepairCheck).to receive(:repair!).and_call_original expect_any_instance_of(RepairCheck).not_to receive(:show_error) @@ -196,8 +196,8 @@ describe SystemCheck::SimpleExecutor do end end - context 'when repair fails' do - it 'does not execute #show_error' do + context "when repair fails" do + it "does not execute #show_error" do expect_any_instance_of(RepairCheck).to receive(:repair!) { false } expect_any_instance_of(RepairCheck).to receive(:show_error) @@ -207,43 +207,43 @@ describe SystemCheck::SimpleExecutor do end end - context 'when check implements skip?' do - it 'executes #skip? method' do + context "when check implements skip?" do + it "executes #skip? method" do expect_any_instance_of(SkipCheck).to receive(:skip?).and_call_original subject.run_check(SkipCheck) end - it 'displays .skip_reason' do + it "displays .skip_reason" do expect { subject.run_check(SkipCheck) }.to output(/this is a skip reason/).to_stdout end - it 'displays #skip_reason' do + it "displays #skip_reason" do expect { subject.run_check(DynamicSkipCheck) }.to output(/this is a dynamic skip reason/).to_stdout end - it 'does not execute #check when #skip? is true' do + it "does not execute #check when #skip? is true" do expect_any_instance_of(SkipCheck).not_to receive(:check?) subject.run_check(SkipCheck) end end - context 'when implements a #multi_check' do - it 'executes #multi_check method' do + context "when implements a #multi_check" do + it "executes #multi_check method" do expect_any_instance_of(MultiCheck).to receive(:multi_check) subject.run_check(MultiCheck) end - it 'does not execute #check method' do + it "does not execute #check method" do expect_any_instance_of(MultiCheck).not_to receive(:check) subject.run_check(MultiCheck) end - context 'when check implements #skip?' do - it 'executes #skip? method' do + context "when check implements #skip?" do + it "executes #skip? method" do expect_any_instance_of(SkipMultiCheck).to receive(:skip?).and_call_original subject.run_check(SkipMultiCheck) @@ -251,8 +251,8 @@ describe SystemCheck::SimpleExecutor do end end - context 'when there is an exception' do - it 'rescues the exception' do + context "when there is an exception" do + it "rescues the exception" do expect { subject.run_check(BugousCheck) }.not_to raise_exception end end |