|
1 | 1 | import nock from "nock";
|
2 | 2 |
|
3 |
| -import { isAgentRunning, flushExtension, AGENT_URL } from "./extension"; |
| 3 | +import { isExtensionRunning, flushExtension, EXTENSION_URL } from "./extension"; |
4 | 4 | import mock from "mock-fs";
|
5 | 5 |
|
6 |
| -describe("isAgentRunning", () => { |
| 6 | +describe("isExtensionRunning", () => { |
7 | 7 | afterEach(() => {
|
8 | 8 | mock.restore();
|
9 | 9 | });
|
10 | 10 | it("returns true when agent exists and responds", async () => {
|
11 | 11 | mock({
|
12 | 12 | "/opt/extensions/datadog-agent": Buffer.from([0]),
|
13 | 13 | });
|
14 |
| - const ran = await isAgentRunning(); |
| 14 | + const ran = await isExtensionRunning(); |
15 | 15 | expect(ran).toBeTruthy();
|
16 | 16 | });
|
17 | 17 | it("returns false when agent doesn't exist", async () => {
|
18 | 18 | mock({});
|
19 |
| - const scope = nock(AGENT_URL).get("/lambda/hello").replyWithError("Unreachable"); |
20 |
| - const ran = await isAgentRunning(); |
| 19 | + const scope = nock(EXTENSION_URL).get("/lambda/hello").replyWithError("Unreachable"); |
| 20 | + const ran = await isExtensionRunning(); |
21 | 21 | expect(scope.isDone()).toBeFalsy();
|
22 | 22 | expect(ran).toBeFalsy();
|
23 | 23 | });
|
24 | 24 | });
|
25 | 25 | describe("flushExtension", () => {
|
26 | 26 | it("calls flush on the agent", async () => {
|
27 |
| - const scope = nock(AGENT_URL).post("/lambda/flush", JSON.stringify({})).reply(200); |
| 27 | + const scope = nock(EXTENSION_URL).post("/lambda/flush", JSON.stringify({})).reply(200); |
28 | 28 | await flushExtension();
|
29 | 29 | expect(scope.isDone()).toBeTruthy();
|
30 | 30 | });
|
31 | 31 | it("catches error when flush doesn't respond", async () => {
|
32 |
| - const scope = nock(AGENT_URL).post("/lambda/flush", JSON.stringify({})).replyWithError("Unavailable"); |
| 32 | + const scope = nock(EXTENSION_URL).post("/lambda/flush", JSON.stringify({})).replyWithError("Unavailable"); |
33 | 33 | await flushExtension();
|
34 | 34 | expect(scope.isDone()).toBeTruthy();
|
35 | 35 | });
|
|
0 commit comments