mirror of
https://github.com/web3privacy/explorer-data.git
synced 2024-10-15 12:06:26 +02:00
fix: update test to skip projects that have incorrect formatting and keep building rest of the projects
This commit is contained in:
parent
fa957d8a6b
commit
0f72b9fb5a
1 changed files with 23 additions and 11 deletions
|
@ -27,29 +27,41 @@ const matrix = {
|
||||||
const schemaDir = "./schema";
|
const schemaDir = "./schema";
|
||||||
const schemas = await loadSchemas();
|
const schemas = await loadSchemas();
|
||||||
|
|
||||||
schemas.project.properties.categories.items.enum = w3pd.data.categories.map(c => c.id)
|
schemas.project.properties.categories.items.enum = w3pd.data.categories.map(
|
||||||
|
(c) => c.id
|
||||||
|
);
|
||||||
|
|
||||||
for (const col of Object.keys(w3pd.data)) {
|
for (const col of Object.keys(w3pd.data)) {
|
||||||
const validator = ajv.compile(schemas[matrix[col]]);
|
const validator = ajv.compile(schemas[matrix[col]]);
|
||||||
const ids = []
|
const ids = [];
|
||||||
|
|
||||||
for (const item of w3pd.data[col]) {
|
for (const item of w3pd.data[col]) {
|
||||||
delete item._path
|
delete item._path;
|
||||||
const testName = `${col}/${item.id} ` + (col === 'projects' ? `[${item.categories?.join(', ')}]` : '')
|
const testName =
|
||||||
|
`${col}/${item.id} ` +
|
||||||
|
(col === "projects"
|
||||||
|
? `[${
|
||||||
|
Array.isArray(item.categories)
|
||||||
|
? item.categories.join(", ")
|
||||||
|
: item.categories
|
||||||
|
}]`
|
||||||
|
: "");
|
||||||
|
|
||||||
if (ids.includes(item.id)) {
|
if (ids.includes(item.id)) {
|
||||||
Deno.test(testName + ' (id-duplicates)', () => {
|
Deno.test(testName + " (id-duplicates)", () => {
|
||||||
throw { message: `Duplicate project id="${item.id}"` }
|
throw { message: `Duplicate project id="${item.id}"` };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Object.keys(item).length > 1) {
|
if (Object.keys(item).length > 1) {
|
||||||
Deno.test(testName + ' (schema)', () => {
|
Deno.test(testName + " (schema)", () => {
|
||||||
if (!validator(item)) {
|
if (!validator(item)) {
|
||||||
throw validator.errors;
|
// throw validator.errors;
|
||||||
|
// log instead of throwing to proceed building all projects
|
||||||
|
console.log(validator.errors);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ids.push(item.id)
|
ids.push(item.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue