mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-17 04:15:13 +00:00
feat(ci): validation
This commit is contained in:
1 parent
2b5e7afd99
commit
94d1338529
9 files changed
+538
-30
No files matched your search
@@ -0,0 +1,40 @@
|
||||
const t = require("ava");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
|
||||
const domainsPath = path.resolve("domains");
|
||||
const files = fs.readdirSync(domainsPath);
|
||||
|
||||
// Nested subdomains should not exist if the parent subdomain does not exist
|
||||
t("Nested subdomains should not exist without a parent subdomain", (t) => {
|
||||
files.forEach((file) => {
|
||||
const subdomain = file.replace(".json", "");
|
||||
|
||||
if (subdomain.split(".").length > 1) {
|
||||
const parentSubdomain = subdomain.split(".").pop();
|
||||
|
||||
t.true(
|
||||
files.includes(`${parentSubdomain}.json`),
|
||||
`${file}: Parent subdomain does not exist`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
t.pass();
|
||||
});
|
||||
|
||||
// Nested subdomains should not exist if the parent subdomain has NS records
|
||||
t("Nested subdomains should not exist if the parent subdomain has NS records", (t) => {
|
||||
files.forEach((file) => {
|
||||
const subdomain = file.replace(".json", "");
|
||||
|
||||
if (subdomain.split(".").length > 1) {
|
||||
const parentSubdomain = subdomain.split(".").pop();
|
||||
const parentDomain = fs.readJsonSync(path.join(domainsPath, `${parentSubdomain}.json`));
|
||||
|
||||
t.is(parentDomain.record.NS, undefined, `${file}: Parent subdomain has NS records`);
|
||||
}
|
||||
});
|
||||
|
||||
t.pass();
|
||||
});
|
||||
Reference in new issue
Block a user