diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/tasks/gitlab | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/tasks/gitlab')
-rw-r--r-- | spec/tasks/gitlab/git_rake_spec.rb | 34 | ||||
-rw-r--r-- | spec/tasks/gitlab/packages/events_rake_spec.rb | 4 | ||||
-rw-r--r-- | spec/tasks/gitlab/pages_rake_spec.rb | 67 |
3 files changed, 103 insertions, 2 deletions
diff --git a/spec/tasks/gitlab/git_rake_spec.rb b/spec/tasks/gitlab/git_rake_spec.rb index 4bc1b460d9b..4d89b126c9e 100644 --- a/spec/tasks/gitlab/git_rake_spec.rb +++ b/spec/tasks/gitlab/git_rake_spec.rb @@ -19,4 +19,38 @@ RSpec.describe 'gitlab:git rake tasks' do expect { run_rake_task('gitlab:git:fsck') }.to output(/Performed integrity check for/).to_stdout end end + + describe 'checksum_projects' do + it 'outputs the checksum for a repo' do + expected = /#{project.id},#{project.repository.checksum}/ + + expect { run_rake_task('gitlab:git:checksum_projects') }.to output(expected).to_stdout + end + + it 'outputs blank checksum for no repo' do + no_repo = create(:project) + + expected = /#{no_repo.id},$/ + + expect { run_rake_task('gitlab:git:checksum_projects') }.to output(expected).to_stdout + end + + it 'outputs zeroes for empty repo' do + empty_repo = create(:project, :empty_repo) + + expected = /#{empty_repo.id},0000000000000000000000000000000000000000/ + + expect { run_rake_task('gitlab:git:checksum_projects') }.to output(expected).to_stdout + end + + it 'outputs errors' do + allow_next_found_instance_of(Project) do |project| + allow(project).to receive(:repo_exists?).and_raise('foo') + end + + expected = /#{project.id},Ignored error: foo/ + + expect { run_rake_task('gitlab:git:checksum_projects') }.to output(expected).to_stdout + end + end end diff --git a/spec/tasks/gitlab/packages/events_rake_spec.rb b/spec/tasks/gitlab/packages/events_rake_spec.rb index a485dc2ce58..d6aa6deac1e 100644 --- a/spec/tasks/gitlab/packages/events_rake_spec.rb +++ b/spec/tasks/gitlab/packages/events_rake_spec.rb @@ -38,8 +38,8 @@ RSpec.describe 'gitlab:packages:events namespace rake task' do end end - describe 'generate_guest' do - let(:task) { 'generate_guest' } + describe 'generate_counts' do + let(:task) { 'generate_counts' } Packages::Event::EVENT_SCOPES.keys.each do |event_scope| it "includes `#{event_scope}` scope" do diff --git a/spec/tasks/gitlab/pages_rake_spec.rb b/spec/tasks/gitlab/pages_rake_spec.rb new file mode 100644 index 00000000000..76808f52890 --- /dev/null +++ b/spec/tasks/gitlab/pages_rake_spec.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'rake_helper' + +RSpec.describe 'gitlab:pages:migrate_legacy_storagerake task' do + before(:context) do + Rake.application.rake_require 'tasks/gitlab/pages' + end + + subject { run_rake_task('gitlab:pages:migrate_legacy_storage') } + + let(:project) { create(:project) } + + it 'does not try to migrate pages if pages are not deployed' do + expect(::Pages::MigrateLegacyStorageToDeploymentService).not_to receive(:new) + + subject + end + + context 'when pages are marked as deployed' do + before do + project.mark_pages_as_deployed + end + + context 'when pages directory does not exist' do + it 'tries to migrate the project, but does not crash' do + expect_next_instance_of(::Pages::MigrateLegacyStorageToDeploymentService, project) do |service| + expect(service).to receive(:execute).and_call_original + end + + subject + end + end + + context 'when pages directory exists on disk' do + before do + FileUtils.mkdir_p File.join(project.pages_path, "public") + File.open(File.join(project.pages_path, "public/index.html"), "w") do |f| + f.write("Hello!") + end + end + + it 'migrates pages projects without deployments' do + expect_next_instance_of(::Pages::MigrateLegacyStorageToDeploymentService, project) do |service| + expect(service).to receive(:execute).and_call_original + end + + expect do + subject + end.to change { project.pages_metadatum.reload.pages_deployment }.from(nil) + end + + context 'when deployed already exists for the project' do + before do + deployment = create(:pages_deployment, project: project) + project.set_first_pages_deployment!(deployment) + end + + it 'does not try to migrate project' do + expect(::Pages::MigrateLegacyStorageToDeploymentService).not_to receive(:new) + + subject + end + end + end + end +end |