Skip to content

Commit

Permalink
test: マニフェスト存在確認
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba committed Jan 21, 2025
1 parent d573603 commit 9ee5f33
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions tests/unit/backend/electron/vvppFile.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ test("正しいVVPPファイルからエンジンを切り出せる", async () =
const sourceDir = path.join(__dirname, "vvpps", targetName);
const outputFilePath = path.join(tmpDir, uuid4() + targetName);
await createZipFile(sourceDir, outputFilePath);

const vvppEngineDir = createVvppEngineDir();
await extractVvpp({
vvppLikeFilePath: outputFilePath,
vvppEngineDir: tmpDir,
vvppEngineDir,
tmpDir,
});
expectManifestExists(vvppEngineDir);
});

test("分割されたVVPPファイルからエンジンを切り出せる", async () => {
Expand All @@ -36,11 +39,14 @@ test("分割されたVVPPファイルからエンジンを切り出せる", asyn
const outputFilePath1 = outputFilePath + ".1.vvppp";
const outputFilePath2 = outputFilePath + ".2.vvppp";
splitFile(outputFilePath, outputFilePath1, outputFilePath2);

const vvppEngineDir = createVvppEngineDir();
await extractVvpp({
vvppLikeFilePath: outputFilePath1,
vvppEngineDir: tmpDir,
vvppEngineDir,
tmpDir,
});
expectManifestExists(vvppEngineDir);
});

test.each([
Expand Down Expand Up @@ -70,6 +76,21 @@ async function createZipFile(sourceDir: string, outputFilePath: string) {
await promisify(exec)(command);
}

function createVvppEngineDir() {
const dir = path.join(tmpDir, uuid4());
fs.mkdirSync(dir);
return dir;
}

function expectManifestExists(vvppEngineDir: string) {
const files = fs.readdirSync(vvppEngineDir, { recursive: true });
const manifestExists = files.some(
(file) =>
typeof file === "string" && path.basename(file) == "engine_manifest.json",
);
expect(manifestExists).toBe(true);
}

/** ファイルを2つに分割する */
function splitFile(
inputFilePath: string,
Expand Down

0 comments on commit 9ee5f33

Please sign in to comment.