From cc41a771832a9d44c9a87e25aa784cb904d03fd5 Mon Sep 17 00:00:00 2001 From: Will Chandler Date: Sun, 3 Jun 2018 17:40:49 -0400 Subject: Add timestamps to gitlab-rake gitlab:backup:restore Adds a new method 'puts_time' that prepends the time of a message when printing it. All instances of 'progress.puts' in the gitlab:backup:restore tasks are replaced with puts_time. Example output: 2018-06-03 16:33:25 -0400 -- Restoring uploads .. Closes #46448 --- spec/tasks/gitlab/backup_rake_spec.rb | 37 ++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index c9252bebb2e..70f3d77dc98 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -71,20 +71,29 @@ describe 'gitlab:app namespace rake task' do end.to raise_error(SystemExit) end - it 'invokes restoration on match' do - allow(YAML).to receive(:load_file) - .and_return({ gitlab_version: gitlab_version }) - expect(Rake::Task['gitlab:db:drop_tables']).to receive(:invoke) - expect(Rake::Task['gitlab:backup:db:restore']).to receive(:invoke) - expect(Rake::Task['gitlab:backup:repo:restore']).to receive(:invoke) - expect(Rake::Task['gitlab:backup:builds:restore']).to receive(:invoke) - expect(Rake::Task['gitlab:backup:uploads:restore']).to receive(:invoke) - expect(Rake::Task['gitlab:backup:artifacts:restore']).to receive(:invoke) - expect(Rake::Task['gitlab:backup:pages:restore']).to receive(:invoke) - expect(Rake::Task['gitlab:backup:lfs:restore']).to receive(:invoke) - expect(Rake::Task['gitlab:backup:registry:restore']).to receive(:invoke) - expect(Rake::Task['gitlab:shell:setup']).to receive(:invoke) - expect { run_rake_task('gitlab:backup:restore') }.to output.to_stdout + context 'restore with matching gitlab version' do + before do + allow(YAML).to receive(:load_file) + .and_return({ gitlab_version: gitlab_version }) + expect(Rake::Task['gitlab:db:drop_tables']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:db:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:repo:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:builds:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:uploads:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:artifacts:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:pages:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:lfs:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:registry:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:shell:setup']).to receive(:invoke) + end + + it 'invokes restoration on match' do + expect { run_rake_task('gitlab:backup:restore') }.to output.to_stdout + end + + it 'prints timestamps on messages' do + expect { run_rake_task('gitlab:backup:restore') }.to output(/.*\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\s[-+]\d{4}\s--\s.*/).to_stdout + end end end end # backup_restore task -- cgit v1.2.3