Skip to content

Commit

Permalink
changed error message and integ test
Browse files Browse the repository at this point in the history
  • Loading branch information
mickychetta committed Jan 10, 2022
1 parent d79b81c commit ab75100
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ export class Route53ToApiGateway extends Construct {
super(scope, id);
defaults.CheckProps(props);

// Certificate must already be issued when the user is bringing an existing one
// If you are using privateHostedZoneProps, the certificate must already be issued
// from a previous domain in order to be used in the newly created Private Hosted Zone.
this.certificate = props.existingCertificateInterface;

if (props.existingVpc) {
Expand All @@ -105,14 +102,14 @@ export class Route53ToApiGateway extends Construct {
throw new Error('Cannot provide an existing VPC to an existing Private Hosted Zone.');
}
if (props.privateHostedZoneProps) {
throw new Error('Must provide either existingHostedZoneInterface or privateHostedZoneProps.');
throw new Error('Must provide either existingHostedZoneInterface or privateHostedZoneProps, but not both.');
}
} else { // Creating a Private Hosted Zone
if (props.publicApi) {
throw new Error('Public APIs require an existingHostedZone be passed in the Props object.');
} else {
if (!props.privateHostedZoneProps) {
throw new Error('Must supply privateHostedZoneProps to create a private API.');
throw new Error('Must provide either existingHostedZoneInterface or privateHostedZoneProps.');
}
if (props.privateHostedZoneProps.vpc) {
throw new Error('All VPC specs must be provided at the Construct level in Route53ToApiGatewayProps.');
Expand All @@ -121,7 +118,7 @@ export class Route53ToApiGateway extends Construct {
throw new Error('Must supply zoneName for Private Hosted Zone Props.');
}
if ( !this.vpc ) {
throw new Error('Must supply an existing VPC for Private Hosted Zone Props.');
throw new Error('Must specify an existingVPC for the Private Hosted Zone in the construct props.');
}
const manufacturedProps: route53.PrivateHostedZoneProps = defaults.overrideProps(props.privateHostedZoneProps, { vpc: this.vpc });
this.hostedZone = new route53.PrivateHostedZone(this, `${id}-zone`, manufacturedProps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ test("Test for errors when creating a private hosted zone", () => {

// Assertion 2
expect(app).toThrowError(
"Must supply privateHostedZoneProps to create a private API"
"Must provide either existingHostedZoneInterface or privateHostedZoneProps."
);

app = () =>
Expand Down Expand Up @@ -178,7 +178,7 @@ test("Test for errors when creating a private hosted zone", () => {

// Assertion 5
expect(app).toThrowError(
"Must provide either existingHostedZoneInterface or privateHostedZoneProps."
"Must provide either existingHostedZoneInterface or privateHostedZoneProps, but not both."
);

app = () =>
Expand All @@ -191,7 +191,7 @@ test("Test for errors when creating a private hosted zone", () => {
existingCertificateInterface: certificate
});

// Assertion 7
// Assertion 6
expect(app).toThrowError(
'Must supply zoneName for Private Hosted Zone Props.'
);
Expand All @@ -206,9 +206,9 @@ test("Test for errors when creating a private hosted zone", () => {
existingCertificateInterface: certificate
});

// Assertion 6
// Assertion 7
expect(app).toThrowError(
'Must supply an existing VPC for Private Hosted Zone Props.'
'Must specify an existingVPC for the Private Hosted Zone in the construct props.'
);
});

Expand Down Expand Up @@ -272,7 +272,7 @@ test("Integration test for A record creation in Public Hosted Zone ", () => {
deployApi(stack, true);

// Assertions
expect(stack).toHaveResourceLike("AWS::Route53::RecordSet", {
expect(stack).toHaveResource("AWS::Route53::RecordSet", {
Name: "www.test-example.com.",
Type: "A",
AliasTarget: {
Expand Down Expand Up @@ -313,7 +313,7 @@ test("Integration test for A record creation in Private Hosted Zone ", () => {
deployApi(stack, false);

// Assertions
expect(stack).toHaveResourceLike("AWS::Route53::RecordSet", {
expect(stack).toHaveResource("AWS::Route53::RecordSet", {
Name: "www.test-example.com.",
Type: "A",
AliasTarget: {
Expand Down

0 comments on commit ab75100

Please sign in to comment.