diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-10-30 14:37:40 +0100 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-10-30 15:53:46 +0100 |
commit | 81f5955eb6677849c15d35b60223312f6a9d77a3 (patch) | |
tree | 3bf5e7a613e5ae0e732aefb153f967340a0a6a8f /spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb | |
parent | 912741cfea06ead8dad95d20f2f0adb955a55732 (diff) | |
download | gitlab-ce-81f5955eb6677849c15d35b60223312f6a9d77a3.tar.gz |
Move Repository#wrapped_gitaly_errors into concern
Having this in a concern allows us to reuse it for different single
purpose classes that call out to git without going through the
repository every time.
Diffstat (limited to 'spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb')
-rw-r--r-- | spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb | 28 |
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 |