diff --git a/translate/test/v3/translate_batch_translate_text_with_glossary.test.js b/translate/test/v3/translate_batch_translate_text_with_glossary.test.js index f6ced2dc303..4a792d9a05b 100644 --- a/translate/test/v3/translate_batch_translate_text_with_glossary.test.js +++ b/translate/test/v3/translate_batch_translate_text_with_glossary.test.js @@ -25,6 +25,20 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const REGION_TAG = 'translate_batch_translate_text_with_glossary'; +async function clearBucket(projectId, storage, bucketUuid) { + const options = { + prefix: `translation-${bucketUuid}/BATCH_TRANSLATE_WITH_GLOS_OUTPUT/`, + delimeter: '/', + }; + + const bucket = await storage.bucket(projectId); + const [files] = await bucket.getFiles(options); + const length = files.length; + if (length > 0) { + await Promise.all(files.map(file => file.delete())); + } +} + describe(REGION_TAG, () => { const translationClient = new TranslationServiceClient(); const location = 'us-central1'; @@ -71,9 +85,10 @@ describe(REGION_TAG, () => { await operation.promise(); }); - it('should batch translate the input text with a glossary', async function () { - this.retries(3); + it('should batch translate the input text with a glossary', async () => { const projectId = await translationClient.getProjectId(); + // make sure the bucket is empty. + await clearBucket(projectId, storage, bucketUuid); const inputUri = 'gs://cloud-samples-data/translation/text.txt'; const outputUri = `gs://${projectId}/${bucketName}`;