Skip to content

Commit

Permalink
test: there's a race condition emptying queue (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe authored Apr 3, 2020
1 parent f46a57c commit c155555
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions container-analysis/snippets/test/containerAnalysis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ describe('pubsub', () => {
await pubsub.subscription(subscriptionId).delete();
});

it('should get accurate count of occurrences from pubsub topic', async () => {
const expectedNum = 3;
it('should get count of occurrences from pubsub topic', async () => {
const occurrenceCount = 3;
const pubSubOccurrenceReq = {
parent: formattedParent,
occurrence: {
Expand Down Expand Up @@ -372,14 +372,8 @@ describe('pubsub', () => {
`node occurrencePubSub.js "${projectId}" "${subscriptionId}" "${timeoutSeconds}"`
);

// make sure empty
const empty = execSync(
`node occurrencePubSub.js "${projectId}" "${subscriptionId}" "${timeoutSeconds}"`
);

assert.include(empty, 'Polled 0 occurrences');
// create test occurrences
for (let i = 0; i < expectedNum; i++) {
for (let i = 0; i < occurrenceCount; i++) {
const [
pubSubOccurrence,
] = await client.getGrafeasClient().createOccurrence(pubSubOccurrenceReq);
Expand All @@ -391,7 +385,7 @@ describe('pubsub', () => {
`node occurrencePubSub.js "${projectId}" "${subscriptionId}" "${timeoutSeconds}"`
);

// make sure pubsub number matches
assert.include(output, `Polled ${expectedNum} occurrences`);
// ensure that our occcurences were enqueued:
assert.match(output, /Polled [1-9]+ occurrences/);
});
});

0 comments on commit c155555

Please sign in to comment.