diff options
Diffstat (limited to 'spec/lib/backup/files_spec.rb')
-rw-r--r-- | spec/lib/backup/files_spec.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/spec/lib/backup/files_spec.rb b/spec/lib/backup/files_spec.rb index 63f2298357f..232d6a2c849 100644 --- a/spec/lib/backup/files_spec.rb +++ b/spec/lib/backup/files_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe Backup::Files do let(:progress) { StringIO.new } @@ -20,60 +20,60 @@ describe Backup::Files do allow_any_instance_of(described_class).to receive(:progress).and_return(progress) end - describe '#restore' do - subject { described_class.new('registry', '/var/gitlab-registry') } + describe "#restore" do + subject { described_class.new("registry", "/var/gitlab-registry") } let(:timestamp) { Time.utc(2017, 3, 22) } around do |example| Timecop.freeze(timestamp) { example.run } end - describe 'folders with permission' do + describe "folders with permission" do before do allow(subject).to receive(:run_pipeline!).and_return(true) allow(subject).to receive(:backup_existing_files).and_return(true) allow(Dir).to receive(:glob).with("/var/gitlab-registry/*", File::FNM_DOTMATCH).and_return(["/var/gitlab-registry/.", "/var/gitlab-registry/..", "/var/gitlab-registry/sample1"]) end - it 'moves all necessary files' do + it "moves all necessary files" do allow(subject).to receive(:backup_existing_files).and_call_original expect(FileUtils).to receive(:mv).with(["/var/gitlab-registry/sample1"], File.join(Gitlab.config.backup.path, "tmp", "registry.#{Time.now.to_i}")) subject.restore end - it 'raises no errors' do + it "raises no errors" do expect { subject.restore }.not_to raise_error end - it 'calls tar command with unlink' do - expect(subject).to receive(:tar).and_return('blabla-tar') + it "calls tar command with unlink" do + expect(subject).to receive(:tar).and_return("blabla-tar") - expect(subject).to receive(:run_pipeline!).with([%w(gzip -cd), %w(blabla-tar --unlink-first --recursive-unlink -C /var/gitlab-registry -xf -)], any_args) + expect(subject).to receive(:run_pipeline!).with([%w[gzip -cd], %w[blabla-tar --unlink-first --recursive-unlink -C /var/gitlab-registry -xf -]], any_args) subject.restore end end - describe 'folders without permissions' do + describe "folders without permissions" do before do allow(FileUtils).to receive(:mv).and_raise(Errno::EACCES) allow(subject).to receive(:run_pipeline!).and_return(true) end - it 'shows error message' do + it "shows error message" do expect(subject).to receive(:access_denied_error).with("/var/gitlab-registry") subject.restore end end - describe 'folders that are a mountpoint' do + describe "folders that are a mountpoint" do before do allow(FileUtils).to receive(:mv).and_raise(Errno::EBUSY) allow(subject).to receive(:run_pipeline!).and_return(true) end - it 'shows error message' do + it "shows error message" do expect(subject).to receive(:resource_busy_error).with("/var/gitlab-registry") - .and_call_original + .and_call_original expect { subject.restore }.to raise_error(/is a mountpoint/) end |