Skip to content

Commit ed4be4b

Browse files
committed
try to fix test fail
1 parent 303e26b commit ed4be4b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

alchemy/src/aws/vpc.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import {
33
DeleteVpcCommand,
44
DescribeVpcsCommand,
55
EC2Client,
6-
ResourceNotFoundException,
6+
ResourceType,
77
type Tag,
8+
type TagSpecification,
89
} from "@aws-sdk/client-ec2";
910
import type { Context } from "../context";
1011
import { Resource } from "../resource";
@@ -219,7 +220,7 @@ export const Vpc = Resource(
219220
if (this.phase === "delete") {
220221
try {
221222
if (this.output?.id) {
222-
await ignore(ResourceNotFoundException.name, () =>
223+
await ignore("VpcNotFound", () =>
223224
client.send(
224225
new DeleteVpcCommand({
225226
VpcId: this.output.id,
@@ -235,7 +236,7 @@ export const Vpc = Resource(
235236
} else {
236237
try {
237238
// Format tags for AWS API
238-
const tagSpecifications = [];
239+
const tagSpecifications: TagSpecification[] = [];
239240
const tags: Tag[] = [];
240241

241242
if (props.name) {
@@ -256,7 +257,7 @@ export const Vpc = Resource(
256257

257258
if (tags.length > 0) {
258259
tagSpecifications.push({
259-
ResourceType: "vpc",
260+
ResourceType: ResourceType.vpc,
260261
Tags: tags,
261262
});
262263
}

alchemy/test/aws/vpc.test.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,15 @@ describe("Vpc Resource", () => {
7474
// Check if it's in a terminated state or gone from the response
7575
if (getDeletedResponse.Vpcs && getDeletedResponse.Vpcs.length > 0) {
7676
const deletedVpc = getDeletedResponse.Vpcs[0];
77-
expect(deletedVpc.State).toEqual("pending-delete");
77+
// VPC states are "available" or "pending"
78+
expect(deletedVpc.State).toEqual("pending");
7879
} else {
7980
// VPC was successfully deleted
8081
expect(getDeletedResponse.Vpcs?.length).toEqual(0);
8182
}
8283
} catch (error: any) {
8384
// The describe call should fail with a not found error
84-
expect(error.name).toMatch(
85-
/VpcNotFound|InvalidVpcId|ResourceNotFoundException/
86-
);
85+
expect(error.name).toMatch(/VpcNotFound/);
8786
}
8887
}
8988
}

0 commit comments

Comments
 (0)