2020-03-10 20:09:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::Graphql::Timeout do
|
2020-12-09 13:09:48 -05:00
|
|
|
it 'inherits from' do
|
2020-03-10 20:09:09 -04:00
|
|
|
expect(described_class.superclass).to eq GraphQL::Schema::Timeout
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sends the error to our GraphQL logger' do
|
|
|
|
parent_type = double(graphql_name: 'parent_type')
|
|
|
|
field = double(graphql_name: 'field')
|
|
|
|
query = double(query_string: 'query_string', provided_variables: 'provided_variables')
|
|
|
|
error = GraphQL::Schema::Timeout::TimeoutError.new(parent_type, field)
|
|
|
|
|
|
|
|
expect(Gitlab::GraphqlLogger)
|
|
|
|
.to receive(:error)
|
|
|
|
.with(message: 'Timeout on parent_type.field', query: 'query_string', query_variables: 'provided_variables')
|
|
|
|
|
|
|
|
timeout = described_class.new(max_seconds: 30)
|
|
|
|
timeout.handle_timeout(error, query)
|
|
|
|
end
|
|
|
|
end
|