diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2018-08-28 18:42:22 +0200 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2018-08-28 18:42:22 +0200 |
commit | 633a7d87a4643b41efe60fc348582f8f98c12345 (patch) | |
tree | c87f6a008e058637d23f51dfd80934c92fb836d9 /spec | |
parent | b64ba567ff4409a9e10f764297ea110023d4aec8 (diff) | |
download | gitlab-ce-ignore-custom-hooks-error.tar.gz |
WIP ignore custom hooks restore errorignore-custom-hooks-error
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/backup/repository_spec.rb | 27 | ||||
-rw-r--r-- | spec/tasks/gitlab/backup_rake_spec.rb | 14 |
2 files changed, 41 insertions, 0 deletions
diff --git a/spec/lib/backup/repository_spec.rb b/spec/lib/backup/repository_spec.rb index c5a854b5660..a28005d6c5e 100644 --- a/spec/lib/backup/repository_spec.rb +++ b/spec/lib/backup/repository_spec.rb @@ -71,6 +71,33 @@ describe Backup::Repository do end end end + + context 'restore custom hooks' do + let(:project) { create(:project, :repository) } +let(:bundle_path) do + tmp = Tempfile.new(%w[restore .bundle]) + path = tmp.path + tmp.close + project.repository.bundle_to_disk(path) + path +end + +after do + FileUtils.rm_f(bundle_path) +end + + before do +allow(subject).to receive(:path_to_bundle).and_return(bundle_path) + allow_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:restore_custom_hooks).and_raise('restore custom hooks failed') + end + + it 'shows the appropriate error' do + subject.restore + + progress.rewind + expect(progress.read).to include('Failed to restore custom hooks') + end + end end describe '#prepare_directories', :seed_helper do diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index 3ba6caf1337..3ddd3f9a91e 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -150,6 +150,20 @@ describe 'gitlab:app namespace rake task' do end expect(Dir.entries(File.join(repo_path, 'custom_hooks'))).to include("dummy.txt") end + +context 'when custom_hooks.tar is invalid (gitlab-ce#50667)' do + it 'ignores the error' do + expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout +allow_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:restore_custom_hooks).and_raise('restore custom hooks failed') + #expect { + run_rake_task('gitlab:backup:restore') #}.to output.to_stdout + + repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do + project.repository.path + end + expect(File.exist?(File.join(repo_path, 'custom_hooks'))).to be_false + end +end end context 'specific backup tasks' do |