Skip to content

Commit 8193896

Browse files
committed
update tests
1 parent 1cd1b89 commit 8193896

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/metrics/extension.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
import nock from "nock";
22

3-
import { isAgentRunning, flushExtension, AGENT_URL } from "./extension";
3+
import { isExtensionRunning, flushExtension, EXTENSION_URL } from "./extension";
44
import mock from "mock-fs";
55

6-
describe("isAgentRunning", () => {
6+
describe("isExtensionRunning", () => {
77
afterEach(() => {
88
mock.restore();
99
});
1010
it("returns true when agent exists and responds", async () => {
1111
mock({
1212
"/opt/extensions/datadog-agent": Buffer.from([0]),
1313
});
14-
const ran = await isAgentRunning();
14+
const ran = await isExtensionRunning();
1515
expect(ran).toBeTruthy();
1616
});
1717
it("returns false when agent doesn't exist", async () => {
1818
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();
2121
expect(scope.isDone()).toBeFalsy();
2222
expect(ran).toBeFalsy();
2323
});
2424
});
2525
describe("flushExtension", () => {
2626
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);
2828
await flushExtension();
2929
expect(scope.isDone()).toBeTruthy();
3030
});
3131
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");
3333
await flushExtension();
3434
expect(scope.isDone()).toBeTruthy();
3535
});

src/metrics/listener.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import nock from "nock";
22
import mock from "mock-fs";
33

44
import { LogLevel, setLogLevel } from "../utils";
5-
import { AGENT_URL } from "./extension";
5+
import { EXTENSION_URL } from "./extension";
66

77
import { MetricsListener } from "./listener";
88
import StatsDClient from "hot-shots";
@@ -105,7 +105,7 @@ describe("MetricsListener", () => {
105105
expect(spy).toHaveBeenCalledWith(`{"e":1487076708,"m":"my-metric","t":["tag:a","tag:b"],"v":10}\n`);
106106
});
107107
it("always sends metrics to statsD when extension is enabled, ignoring logForwarding=true", async () => {
108-
const flushScope = nock(AGENT_URL).post("/lambda/flush", JSON.stringify({})).reply(200);
108+
const flushScope = nock(EXTENSION_URL).post("/lambda/flush", JSON.stringify({})).reply(200);
109109
mock({
110110
"/opt/extensions/datadog-agent": Buffer.from([0]),
111111
});

0 commit comments

Comments
 (0)