Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletions translate/test/v3/translate_batch_translate_text.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,33 @@ describe(REGION_TAG, () => {
console.error(error);
}
});
}),
it('should batch translate the input text', async function () {
this.retries(3);
const projectId = await translationClient.getProjectId();
await clearBucket(projectId, storage, bucketUuid);
const inputUri = 'gs://cloud-samples-data/translation/text.txt';
});

const outputUri = `gs://${projectId}/${bucketName}`;
const output = execSync(
`node v3/${REGION_TAG}.js ${projectId} ${location} ${inputUri} ${outputUri}`
);
assert.match(output, /Total Characters: 13/);
assert.match(output, /Translated Characters: 13/);
}),
// Delete the folder from GCS for cleanup
after(async () => {
const projectId = await translationClient.getProjectId();
const options = {
prefix: `translation-${bucketUuid}`,
};
it('should batch translate the input text', async function () {
this.retries(3);
const projectId = await translationClient.getProjectId();
await clearBucket(projectId, storage, bucketUuid);
const inputUri = 'gs://cloud-samples-data/translation/text.txt';

const outputUri = `gs://${projectId}/${bucketName}`;
const output = execSync(
`node v3/${REGION_TAG}.js ${projectId} ${location} ${inputUri} ${outputUri}`
);
assert.match(output, /Total Characters: 13/);
assert.match(output, /Translated Characters: 13/);
});
// Delete the folder from GCS for cleanup
after(async () => {
const projectId = await translationClient.getProjectId();
const options = {
prefix: `translation-${bucketUuid}`,
};

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()));
}
});
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()));
}
Comment thread
angelcaamal marked this conversation as resolved.
Outdated
});
});
Loading