-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathautotest.mjs
24 lines (24 loc) · 935 Bytes
/
autotest.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { fetchHTML } from './api/fetcher.js';
import { parser } from './api/parser.js';
import fs from 'fs';
let institutions = JSON.parse(fs.readFileSync('./institutions.json'));
let currentDate = new Date();
let cDay = currentDate.getDate().toString().padStart(2, '0');
let cMonth = (currentDate.getMonth() + 1).toString().padStart(2, '0');
let cYear = currentDate.getFullYear().toString();
let resultPassedString = `${cYear}-${cMonth}-${cDay}`;
let results = [];
for await (let i of institutions) {
console.log(`starting validation for p=${i.project}&e=${i.facility}`);
try {
const html = await fetchHTML({ p: i.project, e: i.facility });
await parser(html);
i.tested = resultPassedString;
} catch (e) {
i.tested = false;
}
results.push(i);
console.log(`finished validation for p=${i.project}&e=${i.facility}`);
fs.writeFileSync('./validated.json', JSON.stringify(results));
console.log(`updated validated.json`);
}