@@ -23,6 +23,7 @@ const uuid = require('uuid');
2323
2424const execSync = cmd => cp . execSync ( cmd , { encoding : 'utf-8' } ) ;
2525
26+ const GLOSSARY_ID = 'DO_NOT_DELETE_TEST_GLOSSARY' ;
2627const REGION_TAG = 'translate_batch_translate_text_with_glossary_and_model' ;
2728
2829async function clearBucket ( projectId , storage , bucketUuid ) {
@@ -42,7 +43,6 @@ async function clearBucket(projectId, storage, bucketUuid) {
4243describe ( REGION_TAG , ( ) => {
4344 const translationClient = new TranslationServiceClient ( ) ;
4445 const location = 'us-central1' ;
45- const glossaryId = `my_test_glossary_${ uuid . v4 ( ) } ` ;
4646 const modelId = 'TRL1218052175389786112' ;
4747 const bucketUuid = uuid . v4 ( ) ;
4848 const bucketName = `translation-${ bucketUuid } /BATCH_TRANSLATE_GLOSS_MODEL_OUTPUT/` ;
@@ -63,27 +63,6 @@ describe(REGION_TAG, () => {
6363 console . error ( error ) ;
6464 }
6565 } ) ;
66-
67- // Create glossary
68- const request = {
69- parent : `projects/${ projectId } /locations/${ location } ` ,
70- glossary : {
71- languageCodesSet : {
72- languageCodes : [ 'en' , 'ja' ] ,
73- } ,
74- inputConfig : {
75- gcsSource : {
76- inputUri : 'gs://cloud-samples-data/translation/glossary_ja.csv' ,
77- } ,
78- } ,
79- name : `projects/${ projectId } /locations/${ location } /glossaries/${ glossaryId } ` ,
80- } ,
81- } ;
82-
83- // Create glossary using a long-running operation.
84- const [ operation ] = await translationClient . createGlossary ( request ) ;
85- // Wait for operation to complete.
86- await operation . promise ( ) ;
8766 } ) ;
8867
8968 it ( 'should batch translate the input text with a glossary' , async function ( ) {
@@ -95,7 +74,7 @@ describe(REGION_TAG, () => {
9574
9675 const outputUri = `gs://${ projectId } /${ bucketName } ` ;
9776 const output = execSync (
98- `node v3/${ REGION_TAG } .js ${ projectId } ${ location } ${ inputUri } ${ outputUri } ${ glossaryId } ${ modelId } `
77+ `node v3/${ REGION_TAG } .js ${ projectId } ${ location } ${ inputUri } ${ outputUri } ${ GLOSSARY_ID } ${ modelId } `
9978 ) ;
10079 assert . match ( output , / T o t a l C h a r a c t e r s : 2 5 / ) ;
10180 assert . match ( output , / T r a n s l a t e d C h a r a c t e r s : 2 5 / ) ;
@@ -117,15 +96,5 @@ describe(REGION_TAG, () => {
11796 if ( length > 0 ) {
11897 await Promise . all ( files . map ( file => file . delete ( ) ) ) ;
11998 }
120-
121- // Delete the Glossary
122- const request = {
123- parent : `projects/${ projectId } /locations/${ location } ` ,
124- name : `projects/${ projectId } /locations/${ location } /glossaries/${ glossaryId } ` ,
125- } ;
126- // Delete glossary using a long-running operation.
127- const [ operation ] = await translationClient . deleteGlossary ( request ) ;
128- // Wait for operation to complete.
129- await operation . promise ( ) ;
13099 } ) ;
131100} ) ;
0 commit comments