Update pr.test.js

This commit is contained in:
Stefano Del Prete
2025-01-02 15:14:10 +01:00
committed by GitHub
parent a0c757d0d2
commit 245662dca2
+9 -3
View File
@@ -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),