summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/import_export/command_line_util_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/import_export/command_line_util_spec.rb')
-rw-r--r--spec/lib/gitlab/import_export/command_line_util_spec.rb23
1 files changed, 20 insertions, 3 deletions
diff --git a/spec/lib/gitlab/import_export/command_line_util_spec.rb b/spec/lib/gitlab/import_export/command_line_util_spec.rb
index 31512259bb1..738a76d3360 100644
--- a/spec/lib/gitlab/import_export/command_line_util_spec.rb
+++ b/spec/lib/gitlab/import_export/command_line_util_spec.rb
@@ -97,7 +97,7 @@ RSpec.describe Gitlab::ImportExport::CommandLineUtil do
include Gitlab::ImportExport::CommandLineUtil
end.new
- expect { klass.tar_cf(archive: 'test', dir: 'test') }.to raise_error(Gitlab::ImportExport::Error, 'System call failed')
+ expect { klass.tar_cf(archive: 'test', dir: 'test') }.to raise_error(Gitlab::ImportExport::Error, 'command exited with error code 1: Error')
end
end
end
@@ -125,14 +125,31 @@ RSpec.describe Gitlab::ImportExport::CommandLineUtil do
end
context 'when something goes wrong' do
- it 'raises an error' do
+ before do
expect(Gitlab::Popen).to receive(:popen).and_return(['Error', 1])
+ end
+ it 'raises an error' do
klass = Class.new do
include Gitlab::ImportExport::CommandLineUtil
end.new
- expect { klass.untar_xf(archive: 'test', dir: 'test') }.to raise_error(Gitlab::ImportExport::Error, 'System call failed')
+ expect { klass.untar_xf(archive: 'test', dir: 'test') }.to raise_error(Gitlab::ImportExport::Error, 'command exited with error code 1: Error')
+ end
+
+ it 'returns false and includes error status' do
+ klass = Class.new do
+ include Gitlab::ImportExport::CommandLineUtil
+
+ attr_accessor :shared
+
+ def initialize
+ @shared = Gitlab::ImportExport::Shared.new(nil)
+ end
+ end.new
+
+ expect(klass.tar_czf(archive: 'test', dir: 'test')).to eq(false)
+ expect(klass.shared.errors).to eq(['command exited with error code 1: Error'])
end
end
end