From 245662dca2eb2ad90ec4a079a6f1a8ed1f3b6c91 Mon Sep 17 00:00:00 2001 From: Stefano Del Prete Date: Thu, 2 Jan 2025 15:14:10 +0100 Subject: [PATCH] Update pr.test.js --- tests/pr.test.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/pr.test.js b/tests/pr.test.js index 118b1a658..bfad9aafe 100644 --- a/tests/pr.test.js +++ b/tests/pr.test.js @@ -13,10 +13,16 @@ const headDomainsPath = path.resolve(`register-${RUN_ID}/domains`); const admins = require("../util/administrators.json").map(admin => admin.toLowerCase()); async function getJSONContent(basePath, fileName) { + const jsonPath = path.join(basePath, fileName) + + if (!fs.existsSync(jsonPath)) { + return 1; + } + try { return await fs.readJson(path.join(basePath, fileName)); } catch { - return null; + return 2; } } @@ -31,7 +37,7 @@ t("Modified JSON files must be owned by the PR author", async (t) => { const domainToCheck = currentDomain || modifiedDomain; - if (!modifiedDomain || !domainToCheck) { + if (modifiedDomain === 2 || domainToCheck === 2) { t.fail(`${file}: Unable to read domain data`); return; } @@ -56,7 +62,7 @@ t("New JSON files must be owned by the PR author", async (t) => { const checks = newDomainFiles.map(async (file) => { const domain = await getJSONContent(domainsPath, file); - if (!domain) return t.fail(`${file}: Unable to read domain data`); + if (!domain === 2) return t.fail(`${file}: Unable to read domain data`); t.true( domain.owner.username.toLowerCase() === PR_AUTHOR || admins.includes(PR_AUTHOR),