Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-10-30 23:43:27 +0300
committerDouwe Maan <douwe@gitlab.com>2018-10-30 23:43:27 +0300
commit7bcd0dc19bfd31e79d52ae148d3edf15b054cb5a (patch)
treed1f4075d37ac5420233fb68dc5b239b827573791 /spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb
parent908a19570fe3bba720eecb7463617184230e429f (diff)
parent81f5955eb6677849c15d35b60223312f6a9d77a3 (diff)
Merge branch 'bvl-move-wrapped-gitaly-errors' into 'master'
Move Repository#wrapped_gitaly_errors into concern See merge request gitlab-org/gitlab-ce!22691
Diffstat (limited to 'spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb')
-rw-r--r--spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb b/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb
new file mode 100644
index 00000000000..bcf4814edb6
--- /dev/null
+++ b/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe Gitlab::Git::WrapsGitalyErrors do
+ subject(:wrapper) do
+ klazz = Class.new { include Gitlab::Git::WrapsGitalyErrors }
+ klazz.new
+ end
+
+ describe "#wrapped_gitaly_errors" do
+ mapping = {
+ GRPC::NotFound => Gitlab::Git::Repository::NoRepository,
+ GRPC::InvalidArgument => ArgumentError,
+ GRPC::BadStatus => Gitlab::Git::CommandError
+ }
+
+ mapping.each do |grpc_error, error|
+ it "wraps #{grpc_error} in a #{error}" do
+ expect { wrapper.wrapped_gitaly_errors { raise grpc_error.new('wrapped') } }
+ .to raise_error(error)
+ end
+ end
+
+ it 'does not swallow other errors' do
+ expect { wrapper.wrapped_gitaly_errors { raise 'raised' } }
+ .to raise_error(RuntimeError)
+ end
+ end
+end