Skip to content

Connectum API Reference / @connectum/events-amqp / testing / FakeAmqpAdapter

Function: FakeAmqpAdapter()

FakeAmqpAdapter(options?): FakeAmqpAdapterInstance

Defined in: packages/events-amqp/src/testing.ts:192

Create a programmable AMQP adapter test double.

Parameters

options?

FakeAmqpAdapterOptions = {}

Returns

FakeAmqpAdapterInstance

Example

typescript
import { FakeAmqpAdapter } from '@connectum/events-amqp/testing';
import { AmqpPublishTimeoutError } from '@connectum/events-amqp';

const fake = FakeAmqpAdapter();
const bus = createEventBus({ adapter: fake, routes: [eventRoutes] });
await bus.start();

// The state-UNKNOWN outcome, untestable against a real broker:
fake.control.nextPublish(new AmqpPublishTimeoutError('no outcome (UNKNOWN)'));
await assert.rejects(() => bus.publish(OrderSchema, order), AmqpPublishTimeoutError);

fake.control.dropConnection();          // disconnected → reconnecting
fake.control.completeRecovery();        // connected { reconnected: true }