debian-mirror-gitlab/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb

32 lines
881 B
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
2018-12-13 13:39:08 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Git::WrapsGitalyErrors do
2018-12-13 13:39:08 +05:30
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,
2021-11-18 22:05:49 +05:30
GRPC::DeadlineExceeded => Gitlab::Git::CommandTimedOut,
2018-12-13 13:39:08 +05:30
GRPC::BadStatus => Gitlab::Git::CommandError
}
mapping.each do |grpc_error, error|
it "wraps #{grpc_error} in a #{error}" do
2021-06-08 01:23:25 +05:30
expect { wrapper.wrapped_gitaly_errors { raise grpc_error, 'wrapped' } }
2018-12-13 13:39:08 +05:30
.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