MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / runTests

Function runTests

tests/schema-validation.test.cjs:210–364  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

208
209// Main test execution
210async function runTests() {
211 log('🧪 Starting JSON Schema Validation Tests', 'info');
212 log('==========================================');
213
214 // Find and load all schemas
215 const schemaPaths = findAllSchemas(SCHEMA_BASE_DIR);
216 const schemas = schemaPaths.map(schemaPath => [
217 schemaPath,
218 loadSchema(schemaPath)
219 ]);
220
221 log(`Found ${schemas.length} schemas to validate`);
222
223 // Test 1: Validate each schema structure
224 await test('All schemas have required fields and valid structure', () => {
225 for (const [schemaPath, schema] of schemas) {
226 const result = validateSchemaStructure(schemaPath, schema);
227 if (result !== true) {
228 return `${path.basename(schemaPath)}: ${result}`;
229 }
230 }
231 return true;
232 });
233
234 // Test 2: Validate schema syntax with AJV
235 await test('All schemas are syntactically valid JSON Schema', async () => {
236 for (const [schemaPath, schema] of schemas) {
237 // Create a new AJV instance for each schema to avoid duplicate ID issues
238 const testAjv = new Ajv({
239 allErrors: true,
240 verbose: true,
241 strict: false,
242 discriminator: true,
243 loadSchema: loadExternalSchema
244 });
245 addFormats(testAjv);
246
247 try {
248 await testAjv.compileAsync(schema);
249 } catch (error) {
250 return `${path.basename(schemaPath)}: ${error.message}`;
251 }
252 }
253 return true;
254 });
255
256 // Test 3: Validate cross-references
257 await test('All $ref cross-references resolve to existing schemas', () => {
258 return validateCrossReferences(schemas);
259 });
260
261 // Test 4: Validate registry consistency
262 await test('Schema registry is consistent with actual schemas', () => {
263 return validateRegistryConsistency();
264 });
265
266 // Test 5: Validate enum schemas
267 await test('All enum schemas have proper enum values', () => {

Callers 1

Calls 7

findAllSchemasFunction · 0.85
validateSchemaStructureFunction · 0.85
validateCrossReferencesFunction · 0.85
logFunction · 0.70
loadSchemaFunction · 0.70
testFunction · 0.70

Tested by

no test coverage detected