-
Notifications
You must be signed in to change notification settings - Fork 451
Expand file tree
/
Copy pathstatus.test.ts
More file actions
51 lines (45 loc) · 1.43 KB
/
status.test.ts
File metadata and controls
51 lines (45 loc) · 1.43 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
40
41
42
43
44
45
46
47
48
49
50
51
import test from "ava";
import { mockCodeQLVersion, setupTests } from "../testing-utils";
import { DiskUsage } from "../util";
import { getCacheKey } from "./status";
setupTests(test);
function makeDiskUsage(totalGiB: number): DiskUsage {
return {
numTotalBytes: totalGiB * 1024 * 1024 * 1024,
numAvailableBytes: 0,
};
}
test("getCacheKey incorporates language, CodeQL version, and disk space", async (t) => {
const codeql = mockCodeQLVersion("2.20.0");
t.is(
await getCacheKey(codeql, "javascript", makeDiskUsage(50)),
"codeql-overlay-status-javascript-2.20.0-runner-50GB",
);
t.is(
await getCacheKey(codeql, "python", makeDiskUsage(50)),
"codeql-overlay-status-python-2.20.0-runner-50GB",
);
t.is(
await getCacheKey(
mockCodeQLVersion("2.21.0"),
"javascript",
makeDiskUsage(50),
),
"codeql-overlay-status-javascript-2.21.0-runner-50GB",
);
t.is(
await getCacheKey(codeql, "javascript", makeDiskUsage(100)),
"codeql-overlay-status-javascript-2.20.0-runner-100GB",
);
});
test("getCacheKey rounds disk space down to nearest 10 GiB", async (t) => {
const codeql = mockCodeQLVersion("2.20.0");
t.is(
await getCacheKey(codeql, "javascript", makeDiskUsage(14)),
"codeql-overlay-status-javascript-2.20.0-runner-10GB",
);
t.is(
await getCacheKey(codeql, "javascript", makeDiskUsage(19)),
"codeql-overlay-status-javascript-2.20.0-runner-10GB",
);
});