Sha256: 94d8d94dcce245fb8220a25231c3e5b8fc064548df8d2c69c0c933840c4b2b3b

Contents?: true

Size: 1.19 KB

Versions: 21

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

# This test can take up to 15s to run because it does retries with exponential backoff
RSpec.describe Dor::Workflow::Client::ConnectionFactory do
  let(:mock_logger) { double('Logger', info: true, debug: true, warn: true) }

  let(:druid) { 'druid:123' }
  let(:request_url) { "http://example.com/objects/#{druid}/workflows/httpException?lane-id=default&version=1" }
  before do
    stub_request(:post, request_url)
      .to_return(status: 500, body: 'Internal error', headers: {})
  end

  let(:client) { Dor::Workflow::Client.new url: 'http://example.com', logger: mock_logger }

  describe '#create_workflow_by_name' do
    subject(:request) { client.create_workflow_by_name(druid, 'httpException', version: '1') }
    it 'logs an error and retry upon a targeted Faraday exception' do
      expect(mock_logger).to receive(:warn)
        .with("retrying connection (1 remaining) to #{request_url}: (Faraday::RetriableResponse)  500")
      expect(mock_logger).to receive(:warn)
        .with("retrying connection (0 remaining) to #{request_url}: (Faraday::RetriableResponse)  500")
      expect { request }.to raise_error Dor::WorkflowException
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
dor-workflow-client-5.0.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-4.1.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-4.0.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.24.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.23.1 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.23.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.22.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.21.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.20.1 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.20.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.19.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.18.1 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.18.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.17.1 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.17.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.16.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.15.1 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.15.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.14.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.13.0 spec/workflow/client/connection_factory_spec.rb