Skip to content

Commit 85c8a8c

Browse files
committed
Add tests for parseRemoteFileAddress
1 parent c7a94c9 commit 85c8a8c

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

src/config/remote-file.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import test from "ava";
2+
3+
import { ConfigurationError } from "../util";
4+
5+
import { parseRemoteFileAddress, RemoteFileAddress } from "./remote-file";
6+
7+
test("expandConfigFileInput accepts full remote addresses", async (t) => {
8+
t.deepEqual(parseRemoteFileAddress("owner/repo/path@ref"), {
9+
owner: "owner",
10+
repo: "repo",
11+
path: "path",
12+
ref: "ref",
13+
} satisfies RemoteFileAddress);
14+
15+
t.deepEqual(
16+
parseRemoteFileAddress("owner/repo/path/to/codeql.yml@ref/feature"),
17+
{
18+
owner: "owner",
19+
repo: "repo",
20+
path: "path/to/codeql.yml",
21+
ref: "ref/feature",
22+
} satisfies RemoteFileAddress,
23+
);
24+
});
25+
26+
test("expandConfigFileInput rejects invalid values", async (t) => {
27+
t.throws(() => parseRemoteFileAddress(" "), {
28+
instanceOf: ConfigurationError,
29+
});
30+
t.throws(() => parseRemoteFileAddress("repo:/absolute"), {
31+
instanceOf: ConfigurationError,
32+
});
33+
t.throws(() => parseRemoteFileAddress("repo:file.yml:unexpected"), {
34+
instanceOf: ConfigurationError,
35+
});
36+
});

0 commit comments

Comments
 (0)