Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should continueOnProblems if `continueOnProblems`', async () => {
// Set batchSize to 1 so it executes serially
objectImport = new CustomObjectsImporter(
{
apiConfig,
batchSize: 1,
continueOnProblems: true,
},
logger
)
// Make two objects invalid
customObjects[0].key = ''
customObjects[1].container = ''
await objectImport.run(customObjects)
const summary = objectImport.summaryReport()
expect(summary).toMatchSnapshot()
const errors = summary.detailedSummary.errors
it('should stop import on first errors by default', async () => {
// Set batchSize to 1 so it executes serially
objectImport = new CustomObjectsImporter(
{ apiConfig, batchSize: 1 },
logger
)
// Make last two objects invalid
customObjects[1].key = ''
customObjects[2].container = ''
try {
await objectImport.run(customObjects)
} catch (e) {
// should create first object
expect(e.summary.createdCount).toBe(1)
// should stop after first error
expect(e.summary.errors).toHaveLength(1)
expect(e.summary).toMatchSnapshot()
beforeEach(() => {
objectImport = new CustomObjectsImporter({ apiConfig }, logger)
customObjects = cloneDeep(allCustomObjects)
})
[allowedTypes.customObject]: (options) => {
const service = new CustomObjectImporter(Object.assign({}, options.config, {
apiConfig: {
host: options.authHost,
projectKey: options.credentials.project_key,
credentials: {
clientId: options.credentials.client_id,
clientSecret: options.credentials.client_secret,
},
apiUrl: options.host,
protocol: options.protocol,
oauth_protocol: options.authProtocol,
},
accessToken: options.accessToken,
batchSize: options.batch,
logger: log,
}))
const processFn = service.processStream.bind(service)