Skip to content

Commit

Permalink
Updated bucket pair tests (pulumi#1252)
Browse files Browse the repository at this point in the history
* Updated bucket pair tests

In this case without the try/catch, if the assert fails you'll get a timeout because the done() won't be called. With the done() in the catch block, it won't and you'll see the error messages

Also updated the GHA so that we actually run these tests

* Fix broken test

(that I deliberately broke to test my code :rolleyes:)
  • Loading branch information
pierskarsenbarg committed Jul 20, 2022
1 parent 071a11b commit c03fc53
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/run-tests-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ jobs:
npm install
$(npm bin)/mocha -r ts-node/register ec2tests.ts
working-directory: ${{ matrix.source-dir }}/mocha
- run: |-
npm install
$(npm bin)/mocha -r ts-node/register bucket_pair_test.ts
working-directory: ${{ matrix.source-dir }}/mocha
strategy:
fail-fast: false
matrix:
Expand Down
15 changes: 12 additions & 3 deletions testing-unit-ts/mocha/bucket_pair_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,18 @@ describe("BucketPair", function() {
const bucketPair = new module.BucketPair('my_content_bucket', 'my_logs_bucket', {});
const outputs = [bucketPair.contentBucket.bucket, bucketPair.logsBucket.bucket];
pulumi.all(outputs).apply(([contentBucketName, logsBucketName]) => {
assert.strictEqual(contentBucketName, 'my_content_bucket');
assert.strictEqual(logsBucketName, 'my_logs_bucket');
done();
try
{
/*
* If you don't have the try/catch in here, if the assert fails it'll just timeout
* If you have the try/catch, the "done()" in the catch block will get hit and it won't time out (async fun)
*/
assert.strictEqual(contentBucketName, 'my_content_bucket');
assert.strictEqual(logsBucketName, 'my_logs_bucket');
done();
} catch(e) {
done(e);
}
});
});
});
Expand Down

0 comments on commit c03fc53

Please sign in to comment.