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

grpc_interceptor_spec.rb « tracing « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7f5aecb7baa965b42a9a7aa9ffa08e8b8a4af503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

require 'fast_spec_helper'

describe Gitlab::Tracing::GRPCInterceptor do
  subject { described_class.instance }

  shared_examples_for "a grpc interceptor method" do
    let(:custom_error) { Class.new(StandardError) }

    it 'yields' do
      expect { |b| method.call(kwargs, &b) }.to yield_control
    end

    it 'propagates exceptions' do
      expect { method.call(kwargs) { raise custom_error } }.to raise_error(custom_error)
    end
  end

  describe '#request_response' do
    let(:method) { subject.method(:request_response) }
    let(:kwargs) { { request: {}, call: {}, method: 'grc_method', metadata: {} } }

    it_behaves_like 'a grpc interceptor method'
  end

  describe '#client_streamer' do
    let(:method) { subject.method(:client_streamer) }
    let(:kwargs) { { requests: [], call: {}, method: 'grc_method', metadata: {} } }

    it_behaves_like 'a grpc interceptor method'
  end

  describe '#server_streamer' do
    let(:method) { subject.method(:server_streamer) }
    let(:kwargs) { { request: {}, call: {}, method: 'grc_method', metadata: {} } }

    it_behaves_like 'a grpc interceptor method'
  end

  describe '#bidi_streamer' do
    let(:method) { subject.method(:bidi_streamer) }
    let(:kwargs) { { requests: [], call: {}, method: 'grc_method', metadata: {} } }

    it_behaves_like 'a grpc interceptor method'
  end
end