Skip to content

Commit

Permalink
Converting to BucketV2, fixes #1716 (#1769)
Browse files Browse the repository at this point in the history
  • Loading branch information
rshade authored Jan 10, 2025
1 parent 42188fc commit beeac20
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion testing-integration-py/resource_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def create_s3_bucket():
# Create an AWS resource (S3 Bucket)
bucket = s3.Bucket(BUCKET_NAME)
bucket = s3.BucketV2(BUCKET_NAME)

# Export the value of the bucket
pulumi.export(OUTPUT_KEY_BUCKET_NAME, bucket.bucket)
Expand Down
8 changes: 4 additions & 4 deletions testing-unit-ts/mocha/bucket_pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import * as pulumi from "@pulumi/pulumi";

export class BucketPair extends pulumi.ComponentResource {

contentBucket: aws.s3.Bucket;
logsBucket: aws.s3.Bucket;
contentBucket: aws.s3.BucketV2;
logsBucket: aws.s3.BucketV2;

constructor(contentBucketName: string, logsBucketName: string, opts: any) {
super("pulumi:examples:BucketPair", "BucketPair", {}, opts);

this.contentBucket = new aws.s3.Bucket("contentBucket", {
this.contentBucket = new aws.s3.BucketV2("contentBucket", {
bucket: contentBucketName,
}, { parent: this });

this.logsBucket = new aws.s3.Bucket("logsBucket", {
this.logsBucket = new aws.s3.BucketV2("logsBucket", {
bucket: logsBucketName,
}, { parent: this });

Expand Down
27 changes: 14 additions & 13 deletions testing-unit-ts/mocha/bucket_pair_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "mocha";
import * as assert from 'assert';

pulumi.runtime.setMocks({
newResource: function(args: pulumi.runtime.MockResourceArgs): {id: string, state: any} {
newResource: function (args: pulumi.runtime.MockResourceArgs): { id: string, state: any } {
switch (args.type) {
default:
return {
Expand All @@ -16,40 +16,41 @@ pulumi.runtime.setMocks({
};
}
},
call: function(args: pulumi.runtime.MockCallArgs) {
call: function (args: pulumi.runtime.MockCallArgs) {
switch (args.token) {
default:
return args;
}
},
});

describe("BucketPair", function() {
describe("BucketPair", function () {
this.timeout(10000); // Extend the timeout for this suite

let module: typeof import("./bucket_pair");

before(async function() {
before(async function () {
this.timeout(10000); // Extend timeout for the import
// It's important to import the program _after_ the mocks are defined.
module = await import("./bucket_pair");
});

describe("constructor", function() {
it("must pass bucket names", function(done) {
describe("constructor", function () {
it("must pass bucket names", function (done) {
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]) => {
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)
*/
try {
console.log("Testing outputs:", { contentBucketName, logsBucketName });
assert.strictEqual(contentBucketName, 'my_content_bucket');
assert.strictEqual(logsBucketName, 'my_logs_bucket');
done();
} catch(e) {
} catch (e) {
done(e);
}
});
});
});
});

0 comments on commit beeac20

Please sign in to comment.