Skip to content

Commit

Permalink
Fail validateLinks script also on fetch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
timroes committed Jun 13, 2022
1 parent 0886ee0 commit 74c4195
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions airbyte-webapp/scripts/validate-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ async function run() {
// Query all domains and wait for results
const results = await Promise.allSettled(
Object.entries(links).map(([key, url]) => {
return fetch(url, { headers: { "user-agent": "ValidateLinksCheck" } }).then((resp) => {
if (resp.status >= 200 && resp.status < 300) {
// Only URLs returning a 200 status code are considered okay
console.log(`✓ [${key}] ${url} returned HTTP ${resp.status}`);
} else {
// Everything else should fail this test
console.error(`X [${key}] ${url} returned HTTP ${resp.status}`);
return fetch(url, { headers: { "user-agent": "ValidateLinksCheck" } })
.then((resp) => {
if (resp.status >= 200 && resp.status < 300) {
// Only URLs returning a 200 status code are considered okay
console.log(`✓ [${key}] ${url} returned HTTP ${resp.status}`);
} else {
// Everything else should fail this test
console.error(`X [${key}] ${url} returned HTTP ${resp.status}`);
return Promise.reject({ key, url });
}
})
.catch((reason) => {
console.error(`X [${key}] ${url} error fetching: ${String(reason)}`);
return Promise.reject({ key, url });
}
});
});
})
);

Expand Down

0 comments on commit 74c4195

Please sign in to comment.