From a93c759af0c38ef32bdd90f02eb5049daf19c450 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Mon, 6 Apr 2020 18:24:54 -0700 Subject: [PATCH] test: address test collisions (#502) Co-authored-by: Justin Beckwith --- .../test/v3beta1/translate_create_glossary_beta.test.js | 4 ++-- .../test/v3beta1/translate_delete_glossary_beta.test.js | 5 +++-- translate/test/v3beta1/translate_get_glossary_beta.test.js | 5 +++-- .../translate_translate_text_with_glossary_beta.test.js | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/translate/test/v3beta1/translate_create_glossary_beta.test.js b/translate/test/v3beta1/translate_create_glossary_beta.test.js index 46832a047d..1959908821 100644 --- a/translate/test/v3beta1/translate_create_glossary_beta.test.js +++ b/translate/test/v3beta1/translate_create_glossary_beta.test.js @@ -22,14 +22,15 @@ const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const REGION_TAG = 'translate_create_glossary_beta'; +const uuid = require('uuid'); describe(REGION_TAG, () => { const translationClient = new TranslationServiceClient(); + const glossaryId = `test-glossary-${uuid.v4()}`; it('should create a glossary', async () => { const projectId = await translationClient.getProjectId(); const location = 'us-central1'; - const glossaryId = 'test-glossary'; const output = execSync( `node v3beta1/${REGION_TAG}.js ${projectId} ${location} ${glossaryId}` ); @@ -42,7 +43,6 @@ describe(REGION_TAG, () => { after('cleanup for glossary create', async () => { const projectId = await translationClient.getProjectId(); const location = 'us-central1'; - const glossaryId = 'test-glossary'; // Delete the glossary to clean up const name = translationClient.glossaryPath( projectId, diff --git a/translate/test/v3beta1/translate_delete_glossary_beta.test.js b/translate/test/v3beta1/translate_delete_glossary_beta.test.js index b38948729d..96de5994a3 100644 --- a/translate/test/v3beta1/translate_delete_glossary_beta.test.js +++ b/translate/test/v3beta1/translate_delete_glossary_beta.test.js @@ -22,11 +22,12 @@ const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const REGION_TAG = 'translate_delete_glossary_beta'; +const uuid = require('uuid'); describe(REGION_TAG, () => { const translationClient = new TranslationServiceClient(); const location = 'us-central1'; - const glossaryId = 'glossary'; + const glossaryId = `test_glossary_${uuid.v4()}`; before(async () => { // Add a glossary to be deleted @@ -64,6 +65,6 @@ describe(REGION_TAG, () => { const output = execSync( `node v3beta1/${REGION_TAG}.js ${projectId} ${location} ${glossaryId}` ); - assert.match(output, /glossary/); + assert.include(output, glossaryId); }); }); diff --git a/translate/test/v3beta1/translate_get_glossary_beta.test.js b/translate/test/v3beta1/translate_get_glossary_beta.test.js index c07a47c504..2d82f6b9ec 100644 --- a/translate/test/v3beta1/translate_get_glossary_beta.test.js +++ b/translate/test/v3beta1/translate_get_glossary_beta.test.js @@ -22,11 +22,12 @@ const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const REGION_TAG = 'translate_get_glossary_beta'; +const uuid = require('uuid'); describe(REGION_TAG, () => { const translationClient = new TranslationServiceClient(); const location = 'us-central1'; - const glossaryId = 'test-glossary'; + const glossaryId = `test-glossary-${uuid.v4()}`; before(async () => { // Add a glossary to get @@ -63,7 +64,7 @@ describe(REGION_TAG, () => { const output = execSync( `node v3beta1/${REGION_TAG}.js ${projectId} ${location} ${glossaryId}` ); - assert.match(output, /test-glossary/); + assert.include(output, glossaryId); }); after(async () => { diff --git a/translate/test/v3beta1/translate_translate_text_with_glossary_beta.test.js b/translate/test/v3beta1/translate_translate_text_with_glossary_beta.test.js index 0c3f44bf0a..193edadf4a 100644 --- a/translate/test/v3beta1/translate_translate_text_with_glossary_beta.test.js +++ b/translate/test/v3beta1/translate_translate_text_with_glossary_beta.test.js @@ -22,11 +22,12 @@ const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const REGION_TAG = 'translate_translate_text_with_glossary_beta'; +const uuid = require('uuid'); describe(REGION_TAG, () => { const translationClient = new TranslationServiceClient(); const location = 'us-central1'; - const glossaryId = 'test-glossary'; + const glossaryId = `test-glossary-${uuid.v4()}`; before(async () => { // Add a glossary to be translate with