Skip to content

Commit 0edfbc4

Browse files
authored
test(samples): Refactor AWS S3 Test Credentials Source (#133)
Also allows the S3 client to be configured in a separate step.
1 parent 122bdbf commit 0edfbc4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

storagetransfer/test/aws-request.test.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ describe('aws-request', () => {
3131
let gcsSinkBucket;
3232

3333
before(async () => {
34-
assert(
35-
process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY,
36-
'environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are required'
37-
);
34+
testBucketManager.setupS3();
3835

3936
projectId = await testBucketManager.getProjectId();
4037
awsSourceBucket = await testBucketManager.generateS3Bucket();

storagetransfer/test/utils/bucket.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const uuid = require('uuid');
2727
class BucketManager {
2828
constructor() {
2929
this.client = new StorageTransferServiceClient();
30-
this.s3 = new AWS.S3({apiVersion: '2006-03-01'});
3130
this.storage = new Storage();
3231

3332
/**
@@ -45,6 +44,10 @@ class BucketManager {
4544
this.s3Buckets = [];
4645
}
4746

47+
setupS3(options = {}) {
48+
this.s3 = new AWS.S3({apiVersion: '2006-03-01', ...options});
49+
}
50+
4851
async getProjectId() {
4952
if (!this._cachedProjectId) {
5053
this._cachedProjectId = await this.storage.getProjectId();

0 commit comments

Comments
 (0)