Skip to content

Commit 79fd24c

Browse files
nnegreybcoe
authored andcommitted
docs: use a fake dataset to make create model testable (#306)
1 parent 9395d88 commit 79fd24c

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

automl/test/language_entity_extraction_create_model.test.js

+10-18
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,24 @@ const {AutoMlClient} = require('@google-cloud/automl').v1;
2020

2121
const cp = require('child_process');
2222

23-
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
24-
25-
const CREATE_MODEL_REGION_TAG = 'language_entity_extraction_create_model';
23+
const CREATE_MODEL_REGION_TAG = 'language_entity_extraction_create_model.js';
2624
const LOCATION = 'us-central1';
27-
const DATASET_ID = 'TEN8374527069979148288';
25+
const DATASET_ID = 'TEN0000000000000000000';
2826

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

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

37-
const create_output = execSync(
38-
`node ${CREATE_MODEL_REGION_TAG}.js ${projectId} ${LOCATION} ${DATASET_ID} extraction_test_create_model`
39-
);
40-
41-
assert.match(create_output, /Training started/);
42-
43-
// operationId = create_output
44-
// .split('Training operation name: ')[1]
45-
// .split('\n')[0];
40+
assert.match(output.stderr, /NOT_FOUND/);
41+
assert.match(output.stderr, /Dataset does not exist./);
4642
});
47-
48-
// after('cancel model training', async () => {
49-
// await client.operationsClient.cancelOperation({name: operationId});
50-
// });
5143
});

0 commit comments

Comments
 (0)