@@ -20,32 +20,24 @@ const {AutoMlClient} = require('@google-cloud/automl').v1;
20
20
21
21
const cp = require ( 'child_process' ) ;
22
22
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' ;
26
24
const LOCATION = 'us-central1' ;
27
- const DATASET_ID = 'TEN8374527069979148288 ' ;
25
+ const DATASET_ID = 'TEN0000000000000000000 ' ;
28
26
29
27
describe ( 'Automl Natural Language Entity Extraction Create Model Test' , ( ) => {
30
28
const client = new AutoMlClient ( ) ;
31
29
// let operationId;
32
30
33
31
// 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.
35
36
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' } ) ;
36
39
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 , / T r a i n i n g s t a r t e d / ) ;
42
-
43
- // operationId = create_output
44
- // .split('Training operation name: ')[1]
45
- // .split('\n')[0];
40
+ assert . match ( output . stderr , / N O T _ F O U N D / ) ;
41
+ assert . match ( output . stderr , / D a t a s e t d o e s n o t e x i s t ./ ) ;
46
42
} ) ;
47
-
48
- // after('cancel model training', async () => {
49
- // await client.operationsClient.cancelOperation({name: operationId});
50
- // });
51
43
} ) ;
0 commit comments