orchestrator-core
Advanced tools
Comparing version 4.10.0-dev.20200813.b4c114e to 4.10.0-dev.20200814.039c236
@@ -5,3 +5,3 @@ { | ||
"description": "Orchestrator for Node.js", | ||
"version": "4.10.0-dev.20200813.b4c114e", | ||
"version": "4.10.0-dev.20200814.039c236", | ||
"license": "MIT", | ||
@@ -37,3 +37,4 @@ "keywords": [ | ||
"mocha": "^5.2.0", | ||
"nyc": "^15.0.0" | ||
"nyc": "^15.0.0", | ||
"fast-text-encoding": "^1.0.3" | ||
}, | ||
@@ -40,0 +41,0 @@ "scripts": { |
@@ -5,4 +5,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
const assert = require('assert'); | ||
const oc = require('../build/orchestrator-core.node'); | ||
const path = require('path'); | ||
const oc = require('../orchestrator-core.node'); | ||
const path = require('path'); | ||
require('fast-text-encoding'); | ||
@@ -84,3 +85,3 @@ // Finds onnx model | ||
// Executed once for this overall suite. | ||
before(async function () { | ||
before(function () { | ||
this.timeout(100000); | ||
@@ -100,29 +101,31 @@ this.orchestrator = new oc.Orchestrator(); | ||
assert.notEqual(nlr, null, 'Orchestrator could not be created'); | ||
}); | ||
it('should load NLR.', async function () { | ||
it('should load NLR.', function () { | ||
// Initialize Orchestrator | ||
this.timeout(60000); | ||
const nlr = new oc.Orchestrator(); | ||
const result = await nlr.loadAsync(); | ||
const result = nlr.load(); | ||
assert.strictEqual(result, true, 'Failed async load'); | ||
}); | ||
it('should fail load bad type.', async function () { | ||
it('should throw load() method must provide valid path to NLR.', async function () { | ||
// Initialize Orchestrator | ||
this.timeout(600); | ||
expected = TypeError; | ||
const nlr = new oc.Orchestrator(); | ||
await assert.rejects( async () => { await nlr.loadAsync(234); }, expected, "Rejects on invalid directory type" ); | ||
assert.throws(() => { nlr.load(234); }, "TypeError: load() method must provide valid path to NLR." ); | ||
}); | ||
it('should create a LabelResolver without a NLR nodel, but with a BLU snapshot.', async function () { | ||
it('should create a LabelResolver without a NLR nodel, but with a BLU snapshot.', function () { | ||
this.timeout(10000); | ||
const orchestrator = new oc.Orchestrator(); | ||
assert.ok(orchestrator.load(), 'cannot load without a NLR'); | ||
const snapshotPath = path.join(__dirname, 'snapshot', 'Email.blu'); | ||
assert.ok(fs.existsSync(snapshotPath), `snapshot file ${snapshotPath} does not exist`); | ||
const snapshotContent = new TextEncoder().encode(fs.readFileSync(snapshotPath)); | ||
assert.ok(snapshotContent.length === 140732, `snapshot content length is ${snapshotContent.length}`); | ||
const labelResolver = await orchestrator.createLabelResolver(snapshotContent); | ||
const snapshotContent = new TextEncoder().encode(fs.readFileSync(snapshotPath, 'utf8')); | ||
assert.ok(snapshotContent.length > 0, `snapshot content length is ${snapshotContent.length}`); | ||
const labelResolver = orchestrator.createLabelResolver(snapshotContent); | ||
assert.ok(labelResolver !== undefined, 'cannot create a labelResolver object'); | ||
@@ -132,11 +135,10 @@ const examples = labelResolver.getExamples(); | ||
}); | ||
it('should fail load bad path.', async function () { | ||
it('should throw Invalid JSON config or path provided', function () { | ||
this.timeout(10000); | ||
expected = Error; | ||
const nlr = new oc.Orchestrator(); | ||
await assert.rejects( async () => { await nlr.loadAsync('/foo/bar/path'); }, expected, "Rejects on invalid directory" ); | ||
assert.throws(() => { nlr.load('/foo/bar/path'); }, /^TypeError: Invalid JSON config or path provided .*/); | ||
}); | ||
it('should fail load - invalid config file.', async function () { | ||
it('should throw Invalid config JSON syntax in config file:.', function () { | ||
this.timeout(10000); | ||
@@ -146,6 +148,6 @@ expected = Error; | ||
const bad_config = path.join(__dirname, 'bad_config'); | ||
assert.throws(() => nlr.load(bad_config), /^TypeError: Invalid config JSON syntax in config file: .*/); | ||
assert.throws(() => { nlr.load(bad_config); }, /^TypeError: Invalid config JSON syntax in config file: .*/); | ||
}); | ||
it('should fail load - no config file.', async function () { | ||
it('should fail load - no config file.', function () { | ||
this.timeout(10000); | ||
@@ -158,3 +160,3 @@ expected = Error; | ||
it('Add example.', async function () { | ||
it('Add example.', function () { | ||
// Arrange | ||
@@ -172,3 +174,3 @@ var labeler = this.orchestrator.createLabelResolver(); | ||
it('Remove example.', async function () { | ||
it('Remove example.', function () { | ||
// Arrange | ||
@@ -194,3 +196,3 @@ var orc = new oc.Orchestrator(); | ||
}); | ||
it('Add example - complex label.', async function () { | ||
it('Add example - complex label.', function () { | ||
// Arrange | ||
@@ -197,0 +199,0 @@ var labeler = this.orchestrator.createLabelResolver(); |
Sorry, the diff of this file is not supported yet
462057
4
325