-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathdescribe-alarms.integration.test.js
More file actions
39 lines (29 loc) · 1.19 KB
/
describe-alarms.integration.test.js
File metadata and controls
39 lines (29 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { describe, it, expect, beforeAll, afterAll } from "vitest";
import { createAlarm, deleteAlarms } from "../libs/cloudwatch-helper.js";
import { runEC2Instance, terminateEC2Instance } from "../libs/ec2-helper.js";
describe("describe-alarms", () => {
/** @type {string} */
const alarmName = "DeleteAlarmsTest";
/** @type {string} */
let instanceIdToTerminate;
beforeAll(async () => {
instanceIdToTerminate = await runEC2Instance();
await createAlarm(alarmName, instanceIdToTerminate);
});
afterAll(async () => {
await terminateEC2Instance(instanceIdToTerminate);
await deleteAlarms([alarmName]);
});
it("should set an alarm to enabled", async () => {
process.env.CLOUDWATCH_ALARM_NAME = alarmName;
const mod = await import("../actions/describe-alarms.js");
/** @type {{ MetricAlarms: { AlarmName: string }[]}} */
const { MetricAlarms } = await mod.default;
const matchingAlarm = MetricAlarms.find(
({ AlarmName }) => AlarmName === process.env.CLOUDWATCH_ALARM_NAME,
);
return expect(matchingAlarm).toBeTruthy();
});
});