How to use @cumulus/test-data - 5 common examples

To help you get started, we’ve selected a few @cumulus/test-data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nasa / cumulus / packages / common / schema.js View on Github external
// Contains helper functions for validating JSON against some of the ingest schemas.

const Ajv = require('ajv');
const ajv = new Ajv();
const commonSchema = require('@cumulus/test-data/schemas/ingest_common_schema.json');
const collectionSchema = require('@cumulus/test-data/schemas/collections_config_schema.json');
const messageSchema = require('@cumulus/test-data/schemas/message_schema.json');

const compiledCommon = ajv.compile(commonSchema);

/**
 * Validates the collection configuration object passed to it. Returns true or false. If invalid it
 * will have a errors attribute on the function with the list of errors.
 */
exports.validateCollectionsConfiguration = ajv.compile(collectionSchema,
  {
    schemas: { 'ingest_common_schema.json': compiledCommon.schema },
    allErrors: true
  });

/**
 * Validates the message against the JSON schema. Returns true or false. If invalid it
 * will have a errors attribute on the function with the list of errors.
 */
exports.validateMessageEnvelope = ajv.compile(messageSchema,
  {
    schemas: { 'ingest_common_schema.json': compiledCommon.schema },
    allErrors: true
  });
github nasa / cumulus / packages / common / schema.js View on Github external
// Contains helper functions for validating JSON against some of the ingest schemas.

const Ajv = require('ajv');
const ajv = new Ajv();
const commonSchema = require('@cumulus/test-data/schemas/ingest_common_schema.json');
const collectionSchema = require('@cumulus/test-data/schemas/collections_config_schema.json');
const messageSchema = require('@cumulus/test-data/schemas/message_schema.json');

const compiledCommon = ajv.compile(commonSchema);

/**
 * Validates the collection configuration object passed to it. Returns true or false. If invalid it
 * will have a errors attribute on the function with the list of errors.
 */
exports.validateCollectionsConfiguration = ajv.compile(collectionSchema,
  {
    schemas: { 'ingest_common_schema.json': compiledCommon.schema },
    allErrors: true
  });

/**
 * Validates the message against the JSON schema. Returns true or false. If invalid it
 * will have a errors attribute on the function with the list of errors.
 */
exports.validateMessageEnvelope = ajv.compile(messageSchema,
github nasa / cumulus / tasks / .deprecated / discover-s3-granules / index.js View on Github external
justLocalRun(async () => {
  const payload = await loadJSONTestData('cumulus_messages/discover-s3-granules.json');
  handler(payload, {}, (e, r) => console.log(e, r));
});
github nasa / cumulus / tasks / post-to-cmr / index.js View on Github external
justLocalRun(async () => {
  const payload = await loadJSONTestData('cumulus_messages/post-to-cmr.json');
  handler(payload, {}, (e, r) => log.info(e, r));
});
github nasa / cumulus / packages / common / schema.js View on Github external
/**
 * Validates the collection configuration object passed to it. Returns true or false. If invalid it
 * will have a errors attribute on the function with the list of errors.
 */
exports.validateCollectionsConfiguration = ajv.compile(collectionSchema,
  {
    schemas: { 'ingest_common_schema.json': compiledCommon.schema },
    allErrors: true
  });

/**
 * Validates the message against the JSON schema. Returns true or false. If invalid it
 * will have a errors attribute on the function with the list of errors.
 */
exports.validateMessageEnvelope = ajv.compile(messageSchema,
  {
    schemas: { 'ingest_common_schema.json': compiledCommon.schema },
    allErrors: true
  });

@cumulus/test-data

Includes the test data for various packages

Apache-2.0
Latest version published 22 days ago

Package Health Score

82 / 100
Full package analysis