Sha256: c07176185a990640ce0295bf60b40c5734a721c4bd9d6127ee5a0db4c3b74b17

Contents?: true

Size: 1.2 KB

Versions: 14

Compression:

Stored size: 1.2 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' }
  before do
    stub_request(:post, "http://example.com/objects/#{druid}/workflows/httpException?lane-id=default")
      .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
    it 'logs an error and retry upon a targeted Faraday exception' do
      expect(mock_logger).to receive(:warn).with('retrying connection (1 remaining) to http://example.com/objects/druid:123/workflows/httpException?lane-id=default: (Faraday::RetriableResponse)  500')
      expect(mock_logger).to receive(:warn).with('retrying connection (0 remaining) to http://example.com/objects/druid:123/workflows/httpException?lane-id=default: (Faraday::RetriableResponse)  500')
      expect { client.create_workflow_by_name(druid, 'httpException') }.to raise_error Dor::WorkflowException
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
dor-workflow-client-3.11.1 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.11.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.10.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.9.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.8.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.7.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.6.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.5.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.4.2 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.4.1 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.4.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.3.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.2.0 spec/workflow/client/connection_factory_spec.rb
dor-workflow-client-3.1.0 spec/workflow/client/connection_factory_spec.rb