Skip to content

Commit b5d3438

Browse files
committed
Refactor tests in output-cache.test.ts to use named imports from output-cache
1 parent 1f46830 commit b5d3438

1 file changed

Lines changed: 15 additions & 24 deletions

File tree

src/cli/output-cache.test.ts

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { getRunnerLogger } from "../logging";
77
import { getTestEnv, setupTests } from "../testing-utils";
88
import * as util from "../util";
99

10-
import * as outputCache from "./output-cache";
10+
import {
11+
getCachedCodeQlVersion,
12+
getCommandCacheFilePath,
13+
} from "./output-cache";
1114

1215
setupTests(test);
1316

@@ -18,7 +21,7 @@ test.serial(
1821
async (t) => {
1922
await util.withTmpDir(async (tmpDir: string) => {
2023
const env = getTestEnv({ [EnvVar.TEMP]: tmpDir });
21-
const cacheFile = outputCache.getCommandCacheFilePath(env);
24+
const cacheFile = getCommandCacheFilePath(env);
2225
fs.writeFileSync(
2326
cacheFile,
2427
JSON.stringify({
@@ -27,12 +30,9 @@ test.serial(
2730
}),
2831
"utf8",
2932
);
30-
t.deepEqual(
31-
outputCache.getCachedCodeQlVersion(logger, env, "/path/to/codeql"),
32-
{
33-
version: "2.20.0",
34-
},
35-
);
33+
t.deepEqual(getCachedCodeQlVersion(logger, env, "/path/to/codeql"), {
34+
version: "2.20.0",
35+
});
3636
});
3737
},
3838
);
@@ -42,7 +42,7 @@ test.serial(
4242
async (t) => {
4343
await util.withTmpDir(async (tmpDir: string) => {
4444
const env = getTestEnv({ [EnvVar.TEMP]: tmpDir });
45-
const cacheFile = outputCache.getCommandCacheFilePath(env);
45+
const cacheFile = getCommandCacheFilePath(env);
4646
fs.writeFileSync(
4747
cacheFile,
4848
JSON.stringify({
@@ -51,10 +51,7 @@ test.serial(
5151
}),
5252
"utf8",
5353
);
54-
t.is(
55-
outputCache.getCachedCodeQlVersion(logger, env, "/path/to/codeql"),
56-
undefined,
57-
);
54+
t.is(getCachedCodeQlVersion(logger, env, "/path/to/codeql"), undefined);
5855
});
5956
},
6057
);
@@ -64,12 +61,9 @@ test.serial(
6461
async (t) => {
6562
await util.withTmpDir(async (tmpDir: string) => {
6663
const env = getTestEnv({ [EnvVar.TEMP]: tmpDir });
67-
const cacheFile = outputCache.getCommandCacheFilePath(env);
64+
const cacheFile = getCommandCacheFilePath(env);
6865
fs.writeFileSync(cacheFile, "not valid json", "utf8");
69-
t.is(
70-
outputCache.getCachedCodeQlVersion(logger, env, "/path/to/codeql"),
71-
undefined,
72-
);
66+
t.is(getCachedCodeQlVersion(logger, env, "/path/to/codeql"), undefined);
7367
});
7468
},
7569
);
@@ -79,7 +73,7 @@ test.serial(
7973
async (t) => {
8074
await util.withTmpDir(async (tmpDir: string) => {
8175
const env = getTestEnv({ [EnvVar.TEMP]: tmpDir });
82-
const cacheFile = outputCache.getCommandCacheFilePath(env);
76+
const cacheFile = getCommandCacheFilePath(env);
8377
const testValues = [
8478
{ cmd: "/path/to/codeql" },
8579
{ entries: { version: { version: "2.20.0" } } },
@@ -104,7 +98,7 @@ test.serial(
10498
for (const value of testValues) {
10599
fs.writeFileSync(cacheFile, value, "utf8");
106100
t.is(
107-
outputCache.getCachedCodeQlVersion(logger, env, "/path/to/codeql"),
101+
getCachedCodeQlVersion(logger, env, "/path/to/codeql"),
108102
undefined,
109103
value,
110104
);
@@ -117,10 +111,7 @@ test.serial("getCachedCodeQlVersion ignores non-existent file", async (t) => {
117111
await util.withTmpDir(async (tmpDir: string) => {
118112
const env = getTestEnv({ [EnvVar.TEMP]: tmpDir });
119113
t.notThrows(() => {
120-
t.is(
121-
outputCache.getCachedCodeQlVersion(logger, env, "/path/to/codeql"),
122-
undefined,
123-
);
114+
t.is(getCachedCodeQlVersion(logger, env, "/path/to/codeql"), undefined);
124115
});
125116
});
126117
});

0 commit comments

Comments
 (0)