Skip to content

Commit dd76977

Browse files
committed
Add a test for infinite looping when readClosest cannot find a file in node.js
1 parent f96abc2 commit dd76977

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { assertThrows } from "$std/assert/mod.ts";
2+
import { readClosest } from "../src/platform.node.ts";
3+
4+
Deno.test("Node.js platform tests", async (t) => {
5+
// NOTE: Added this test as a quick way to cover the fix from #149 - fix an infinite loop which happens when autometrics is initialized in a node service without a git repository
6+
await t.step(
7+
"readClosest does not loop infinitely on nonexistent file",
8+
() => {
9+
assertThrows(
10+
() => readClosest("nonexistent.file"),
11+
Error,
12+
"Could not read nonexistent.file",
13+
);
14+
},
15+
);
16+
});

0 commit comments

Comments
 (0)