Skip to content

Commit

Permalink
docs: use a fake dataset to make create model testable (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
nnegrey authored and bcoe committed Jan 2, 2020
1 parent 9395d88 commit 79fd24c
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions automl/test/language_entity_extraction_create_model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,24 @@ const {AutoMlClient} = require('@google-cloud/automl').v1;

const cp = require('child_process');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const CREATE_MODEL_REGION_TAG = 'language_entity_extraction_create_model';
const CREATE_MODEL_REGION_TAG = 'language_entity_extraction_create_model.js';
const LOCATION = 'us-central1';
const DATASET_ID = 'TEN8374527069979148288';
const DATASET_ID = 'TEN0000000000000000000';

describe('Automl Natural Language Entity Extraction Create Model Test', () => {
const client = new AutoMlClient();
// let operationId;

// Natural language entity extraction models are non cancellable operations
it.skip('should create a model', async () => {
it('should create a model', async () => {
// As entity extraction does not let you cancel model creation, instead try
// to create a model from a nonexistent dataset, but other elements of the
// request were valid.
const projectId = await client.getProjectId();
const args = [CREATE_MODEL_REGION_TAG, projectId, LOCATION, DATASET_ID];
const output = cp.spawnSync('node', args, {encoding: 'utf8'});

const create_output = execSync(
`node ${CREATE_MODEL_REGION_TAG}.js ${projectId} ${LOCATION} ${DATASET_ID} extraction_test_create_model`
);

assert.match(create_output, /Training started/);

// operationId = create_output
// .split('Training operation name: ')[1]
// .split('\n')[0];
assert.match(output.stderr, /NOT_FOUND/);
assert.match(output.stderr, /Dataset does not exist./);
});

// after('cancel model training', async () => {
// await client.operationsClient.cancelOperation({name: operationId});
// });
});

0 comments on commit 79fd24c

Please sign in to comment.