Add unit tests for getCgroupCpuCountFromCpus
This commit is contained in:
parent
ef0a773901
commit
8cb81db135
6 changed files with 59 additions and 4 deletions
21
lib/util.test.js
generated
21
lib/util.test.js
generated
|
|
@ -354,4 +354,25 @@ for (const [version, githubVersion, shouldReportWarning,] of CHECK_ACTION_VERSIO
|
|||
versionStub.restore();
|
||||
});
|
||||
}
|
||||
(0, ava_1.default)("getCgroupCpuCountFromCpus calculates the number of CPUs correctly", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const testCpuFile = `${tmpDir}/cpus-file`;
|
||||
fs.writeFileSync(testCpuFile, "1, 9-10\n", "utf-8");
|
||||
t.deepEqual(util.getCgroupCpuCountFromCpus(testCpuFile, (0, logging_1.getRunnerLogger)(true)), 3);
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("getCgroupCpuCountFromCpus returns undefined if the CPU file doesn't exist", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const testCpuFile = `${tmpDir}/cpus-file`;
|
||||
t.false(fs.existsSync(testCpuFile));
|
||||
t.deepEqual(util.getCgroupCpuCountFromCpus(testCpuFile, (0, logging_1.getRunnerLogger)(true)), undefined);
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("getCgroupCpuCountFromCpus returns undefined if the CPU file exists but is empty", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const testCpuFile = `${tmpDir}/cpus-file`;
|
||||
fs.writeFileSync(testCpuFile, "\n", "utf-8");
|
||||
t.deepEqual(util.getCgroupCpuCountFromCpus(testCpuFile, (0, logging_1.getRunnerLogger)(true)), undefined);
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=util.test.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue