Skip to content

Commit 0936993

Browse files
munkhuushmglAce Nassri
authored and
Ace Nassri
committed
test: ensure output dir is empty (#637)
1 parent ca41d38 commit 0936993

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

translate/test/v3/translate_batch_translate_text_with_glossary.test.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2525

2626
const REGION_TAG = 'translate_batch_translate_text_with_glossary';
2727

28+
async function clearBucket(projectId, storage, bucketUuid) {
29+
const options = {
30+
prefix: `translation-${bucketUuid}/BATCH_TRANSLATE_WITH_GLOS_OUTPUT/`,
31+
delimeter: '/',
32+
};
33+
34+
const bucket = await storage.bucket(projectId);
35+
const [files] = await bucket.getFiles(options);
36+
const length = files.length;
37+
if (length > 0) {
38+
await Promise.all(files.map(file => file.delete()));
39+
}
40+
}
41+
2842
describe(REGION_TAG, () => {
2943
const translationClient = new TranslationServiceClient();
3044
const location = 'us-central1';
@@ -71,9 +85,10 @@ describe(REGION_TAG, () => {
7185
await operation.promise();
7286
});
7387

74-
it('should batch translate the input text with a glossary', async function () {
75-
this.retries(3);
88+
it('should batch translate the input text with a glossary', async () => {
7689
const projectId = await translationClient.getProjectId();
90+
// make sure the bucket is empty.
91+
await clearBucket(projectId, storage, bucketUuid);
7792
const inputUri = 'gs://cloud-samples-data/translation/text.txt';
7893

7994
const outputUri = `gs://${projectId}/${bucketName}`;

0 commit comments

Comments
 (0)