diff options
Diffstat (limited to 'spec/lib/backup/manager_spec.rb')
-rw-r--r-- | spec/lib/backup/manager_spec.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/spec/lib/backup/manager_spec.rb b/spec/lib/backup/manager_spec.rb index 1733d21c23f..8f85cd9d8b3 100644 --- a/spec/lib/backup/manager_spec.rb +++ b/spec/lib/backup/manager_spec.rb @@ -69,7 +69,7 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do let(:pre_restore_warning) { nil } let(:post_restore_warning) { nil } let(:definitions) { { 'my_task' => Backup::Manager::TaskDefinition.new(task: task, enabled: enabled, human_name: 'my task', destination_path: 'my_task.tar.gz') } } - let(:backup_information) { {} } + let(:backup_information) { { backup_created_at: Time.zone.parse('2019-01-01'), gitlab_version: '12.3' } } let(:task) do instance_double(Backup::Task, pre_restore_warning: pre_restore_warning, @@ -156,7 +156,7 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do describe '#create' do let(:incremental_env) { 'false' } - let(:expected_backup_contents) { %w{backup_information.yml task1.tar.gz task2.tar.gz} } + let(:expected_backup_contents) { %w[backup_information.yml task1.tar.gz task2.tar.gz] } let(:backup_time) { Time.zone.parse('2019-1-1') } let(:backup_id) { "1546300800_2019_01_01_#{Gitlab::VERSION}" } let(:full_backup_id) { backup_id } @@ -179,8 +179,8 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do allow(Gitlab::BackupLogger).to receive(:info) allow(Kernel).to receive(:system).and_return(true) - allow(task1).to receive(:dump).with(File.join(Gitlab.config.backup.path, 'task1.tar.gz'), full_backup_id) - allow(task2).to receive(:dump).with(File.join(Gitlab.config.backup.path, 'task2.tar.gz'), full_backup_id) + allow(task1).to receive(:dump).with(File.join(Gitlab.config.backup.path, 'task1.tar.gz'), backup_id) + allow(task2).to receive(:dump).with(File.join(Gitlab.config.backup.path, 'task2.tar.gz'), backup_id) end it 'creates a backup tar' do @@ -223,7 +223,7 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do end context 'when SKIP env is set' do - let(:expected_backup_contents) { %w{backup_information.yml task1.tar.gz} } + let(:expected_backup_contents) { %w[backup_information.yml task1.tar.gz] } before do stub_env('SKIP', 'task2') @@ -237,7 +237,7 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do end context 'when the destination is optional' do - let(:expected_backup_contents) { %w{backup_information.yml task1.tar.gz} } + let(:expected_backup_contents) { %w[backup_information.yml task1.tar.gz] } let(:definitions) do { 'task1' => Backup::Manager::TaskDefinition.new(task: task1, destination_path: 'task1.tar.gz'), @@ -936,6 +936,8 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do end let(:gitlab_version) { Gitlab::VERSION } + let(:backup_id) { "1546300800_2019_01_01_#{gitlab_version}" } + let(:backup_information) do { backup_created_at: Time.zone.parse('2019-01-01'), @@ -948,8 +950,8 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do Rake.application.rake_require 'tasks/cache' allow(Gitlab::BackupLogger).to receive(:info) - allow(task1).to receive(:restore).with(File.join(Gitlab.config.backup.path, 'task1.tar.gz')) - allow(task2).to receive(:restore).with(File.join(Gitlab.config.backup.path, 'task2.tar.gz')) + allow(task1).to receive(:restore).with(File.join(Gitlab.config.backup.path, 'task1.tar.gz'), backup_id) + allow(task2).to receive(:restore).with(File.join(Gitlab.config.backup.path, 'task2.tar.gz'), backup_id) allow(YAML).to receive(:safe_load_file).with(File.join(Gitlab.config.backup.path, 'backup_information.yml'), permitted_classes: described_class::YAML_PERMITTED_CLASSES) .and_return(backup_information) @@ -1013,7 +1015,8 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do end context 'when BACKUP variable is set to a correct file' do - let(:tar_cmdline) { %w{tar -xf 1451606400_2016_01_01_1.2.3_gitlab_backup.tar} } + let(:tar_cmdline) { %w[tar -xf 1451606400_2016_01_01_1.2.3_gitlab_backup.tar] } + let(:backup_id) { "1451606400_2016_01_01_1.2.3" } before do allow(Gitlab::BackupLogger).to receive(:info) |