-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,47 @@ | ||
#! /usr/bin/env node | ||
/* eslint-env node */ | ||
import './lockdown.mjs'; | ||
|
||
import { equal } from 'node:assert/strict'; | ||
import { getQuery, expectations } from './queries.mjs'; | ||
import { assertAllDefined } from '@agoric/internal'; | ||
import { expectations, getQuery } from './queries.mjs'; | ||
|
||
const apiUrl = 'http://localhost:3000/'; | ||
console.log(`API URL set to: ${apiUrl}`); | ||
|
||
const { entity } = process.env; | ||
console.log(`Entity: ${entity}`); | ||
|
||
assertAllDefined({ entity }); | ||
|
||
try { | ||
const graphqlQuery = { query: getQuery(entity) }; | ||
/** | ||
* @param {string} entity | ||
*/ | ||
const checkEntity = async (entity) => { | ||
try { | ||
const graphqlQuery = { query: getQuery(entity) }; | ||
|
||
const response = await fetch(apiUrl, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Accept: 'application/json', | ||
}, | ||
body: JSON.stringify(graphqlQuery), | ||
}); | ||
const response = await fetch(apiUrl, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Accept: 'application/json', | ||
}, | ||
body: JSON.stringify(graphqlQuery), | ||
}); | ||
|
||
const jsonResponse = await response.json(); | ||
console.log('Response:', JSON.stringify(jsonResponse)); | ||
const nodes = jsonResponse?.data[entity]?.nodes; | ||
console.log('Node:', nodes); | ||
const jsonResponse = await response.json(); | ||
console.log('Response:', JSON.stringify(jsonResponse)); | ||
const nodes = jsonResponse?.data[entity]?.nodes; | ||
console.log('Node:', nodes); | ||
|
||
for (const key of Object.keys(expectations[entity])) { | ||
console.log(`Checking ${entity} ${key}...`); | ||
equal(nodes[0]?.[key], expectations[entity][key]), `Expected ${key} to be ${expectations[entity][key]}`; | ||
for (const key of Object.keys(expectations[entity])) { | ||
equal(nodes[0]?.[key], expectations[entity][key]), `Expected ${key} to be ${expectations[entity][key]}`; | ||
} | ||
} catch (error) { | ||
console.error('Error:', error); | ||
process.exit(1); | ||
} | ||
} catch (error) { | ||
console.error('Error:', error); | ||
process.exit(1); | ||
}; | ||
|
||
for (const entity of Object.keys(expectations)) { | ||
console.log(`Validating ${entity}...`); | ||
await checkEntity(entity); | ||
console.log(`Validation successful for ${entity}.`); | ||
} | ||
|
||
console.log('Validation successful for all entities.'); |