Skip to content

Commit

Permalink
tests: make sure to catch all messages on flaky ordered message test (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
feywind authored May 26, 2023
1 parent d50428b commit bc7e915
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions system-test/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,6 @@ describe('pubsub', () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
} = require('../../system-test/fixtures/ordered-messages.json');

const publishes = input.map(({key, message}: Input) => {
const options: MessageOptions = {
data: Buffer.from(message),
};

if (key) {
options.orderingKey = key;
}

return topic.publishMessage(options);
});

await Promise.all(publishes);

const pending: Pending = {};

expected.forEach(({key, messages}: Expected) => {
Expand All @@ -329,6 +315,7 @@ describe('pubsub', () => {

const deferred = defer();

// Make sure we're listening when the lease manager throws the messages at us.
subscription
.on('error', deferred.reject)
.on('message', (message: Message) => {
Expand Down Expand Up @@ -371,6 +358,19 @@ describe('pubsub', () => {
}
});

const publishes = input.map(({key, message}: Input) => {
const options: MessageOptions = {
data: Buffer.from(message),
};

if (key) {
options.orderingKey = key;
}

return topic.publishMessage(options);
});
await Promise.all(publishes);

await deferred.promise;
await Promise.all([topic.delete(), subscription.delete()]);
});
Expand Down

0 comments on commit bc7e915

Please sign in to comment.