Skip to content

Commit ead4dec

Browse files
authored
Merge branch 'main' into main
2 parents 3f6714e + ec7743e commit ead4dec

7 files changed

Lines changed: 109 additions & 67 deletions

File tree

dialogflow-cx/test/detect-intent-sentiment-analysis-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('detect intent with sentiment analysis', () => {
2929

3030
it('should detect negative sentiment score of user query', async () => {
3131
const output = exec(
32-
`${cmd} ${projectId} ${location} ${agentId} 'I am not happy' ${languageCode}`
32+
`${cmd} ${projectId} ${location} ${agentId} 'I had an accident and I lost my new car' ${languageCode}`
3333
);
3434
assert.include(output, 'negative');
3535
});

dialogflow-cx/test/list_testcase-results.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ describe('Test filtering results', async () => {
2929
const projectId =
3030
process.env.AGENT_PROJECT_ID || (await agentClient.getProjectId());
3131

32-
it('should return filtered test results', async () => {
32+
it('should return filtered test results', function () {
33+
if (!agentId || !testId) {
34+
this.skip();
35+
}
3336
const output = exec(`${cmd} ${projectId} ${agentId} ${testId} ${location}`);
3437
assert.include(output, testId);
3538
});

document-ai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"dependencies": {
1616
"@google-cloud/documentai": "^8.0.0",
1717
"@google-cloud/storage": "^7.0.0",
18-
"p-queue": "^8.0.0"
18+
"p-queue": "^6.6.2"
1919
},
2020
"devDependencies": {
2121
"c8": "^10.0.0",

storagetransfer/test/aws-request.test.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,25 @@ describe('aws-request', () => {
3030
let awsSourceBucket;
3131
let gcsSinkBucket;
3232

33-
before(async () => {
34-
testBucketManager.setupS3();
33+
before(async function () {
34+
try {
35+
testBucketManager.setupS3();
3536

36-
projectId = await testBucketManager.getProjectId();
37-
awsSourceBucket = await testBucketManager.generateS3Bucket();
38-
gcsSinkBucket = (await testBucketManager.generateGCSBucket()).name;
39-
description = `My transfer job from '${awsSourceBucket}' -> '${gcsSinkBucket}'`;
37+
projectId = await testBucketManager.getProjectId();
38+
awsSourceBucket = await testBucketManager.generateS3Bucket();
39+
gcsSinkBucket = (await testBucketManager.generateGCSBucket()).name;
40+
description = `My transfer job from '${awsSourceBucket}' -> '${gcsSinkBucket}'`;
41+
} catch (err) {
42+
if (
43+
err?.code === 'InvalidAccessKeyId' ||
44+
err?.message?.includes('Missing credentials in config')
45+
) {
46+
console.warn('AWS credentials are missing or invalid.');
47+
this.skip();
48+
} else {
49+
throw err;
50+
}
51+
}
4052
});
4153

4254
after(async () => {

storagetransfer/test/azure-request.test.js

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
'use strict';
1818

19+
// Since we are running on Node.js 16, crypto is not available globally.
20+
if (!globalThis.crypto) {
21+
globalThis.crypto = require('node:crypto').webcrypto;
22+
}
23+
1924
const {assert} = require('chai');
2025
const {after, before, describe, it} = require('mocha');
2126

@@ -31,31 +36,44 @@ describe('azure-request', () => {
3136
let azureSourceContainer;
3237
let gcsSinkBucket;
3338

34-
before(async () => {
35-
assert(
36-
process.env.AZURE_CONNECTION_STRING,
37-
'environment variable AZURE_CONNECTION_STRING is required'
38-
);
39-
40-
testBucketManager.setupBlobStorageFromConnectionString(
41-
process.env.AZURE_CONNECTION_STRING
42-
);
43-
44-
azureStorageAccount =
45-
process.env.AZURE_STORAGE_ACCOUNT ||
46-
testBucketManager.blobStorage.accountName;
47-
48-
projectId = await testBucketManager.getProjectId();
49-
azureSourceContainer =
50-
await testBucketManager.generateBlobStorageContainer();
51-
gcsSinkBucket = (await testBucketManager.generateGCSBucket()).name;
52-
description = `My transfer job from '${azureSourceContainer}' -> '${gcsSinkBucket}'`;
53-
54-
if (!process.env.AZURE_SAS_TOKEN) {
55-
// For security purposes we only want to pass this value via environment, not cli
56-
process.env.AZURE_SAS_TOKEN = new URL(
57-
testBucketManager.blobStorage.storageClientContext.url
58-
).search;
39+
before(async function () {
40+
try {
41+
assert(
42+
process.env.AZURE_CONNECTION_STRING,
43+
'environment variable AZURE_CONNECTION_STRING is required'
44+
);
45+
46+
testBucketManager.setupBlobStorageFromConnectionString(
47+
process.env.AZURE_CONNECTION_STRING
48+
);
49+
50+
azureStorageAccount =
51+
process.env.AZURE_STORAGE_ACCOUNT ||
52+
testBucketManager.blobStorage.accountName;
53+
54+
projectId = await testBucketManager.getProjectId();
55+
azureSourceContainer =
56+
await testBucketManager.generateBlobStorageContainer();
57+
gcsSinkBucket = (await testBucketManager.generateGCSBucket()).name;
58+
description = `My transfer job from '${azureSourceContainer}' -> '${gcsSinkBucket}'`;
59+
60+
if (!process.env.AZURE_SAS_TOKEN) {
61+
// For security purposes we only want to pass this value via environment, not cli
62+
process.env.AZURE_SAS_TOKEN = new URL(
63+
testBucketManager.blobStorage.storageClientContext.url
64+
).search;
65+
}
66+
} catch (err) {
67+
if (
68+
err?.name === 'AssertionError' ||
69+
err?.message?.includes('AZURE_CONNECTION_STRING') ||
70+
err?.message?.includes('failed to authenticate')
71+
) {
72+
console.warn('Azure credentials are missing, invalid, or expired.');
73+
this.skip();
74+
} else {
75+
throw err;
76+
}
5977
}
6078
});
6179

storagetransfer/test/event-driven-aws-transfer.test.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,25 @@ describe('event-driven-aws-transfer', () => {
3636
let gcsSinkBucket;
3737
let sqsQueueArn;
3838

39-
before(async () => {
40-
testBucketManager.setupS3();
41-
projectId = await testBucketManager.getProjectId();
42-
s3SourceBucket = await testBucketManager.generateS3Bucket();
43-
gcsSinkBucket = (await testBucketManager.generateGCSBucket()).name;
44-
sqsQueueArn = await testQueueManager.generateSqsQueueArn();
45-
console.log('Arn: ' + sqsQueueArn);
39+
before(async function () {
40+
try {
41+
testBucketManager.setupS3();
42+
projectId = await testBucketManager.getProjectId();
43+
s3SourceBucket = await testBucketManager.generateS3Bucket();
44+
gcsSinkBucket = (await testBucketManager.generateGCSBucket()).name;
45+
sqsQueueArn = await testQueueManager.generateSqsQueueArn();
46+
console.log('Arn: ' + sqsQueueArn);
47+
} catch (err) {
48+
if (
49+
err?.code === 'InvalidAccessKeyId' ||
50+
err?.message?.includes('Missing credentials in config')
51+
) {
52+
console.warn('AWS credentials are missing or invalid.');
53+
this.skip();
54+
} else {
55+
throw err;
56+
}
57+
}
4658
});
4759

4860
after(async () => {

translate/test/v3/translate_batch_translate_text.test.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,29 @@ describe(REGION_TAG, () => {
6161
console.error(error);
6262
}
6363
});
64-
}),
65-
it('should batch translate the input text', async function () {
66-
this.retries(3);
67-
const projectId = await translationClient.getProjectId();
68-
await clearBucket(projectId, storage, bucketUuid);
69-
const inputUri = 'gs://cloud-samples-data/translation/text.txt';
64+
});
7065

71-
const outputUri = `gs://${projectId}/${bucketName}`;
72-
const output = execSync(
73-
`node v3/${REGION_TAG}.js ${projectId} ${location} ${inputUri} ${outputUri}`
74-
);
75-
assert.match(output, /Total Characters: 13/);
76-
assert.match(output, /Translated Characters: 13/);
77-
}),
78-
// Delete the folder from GCS for cleanup
79-
after(async () => {
80-
const projectId = await translationClient.getProjectId();
81-
const options = {
82-
prefix: `translation-${bucketUuid}`,
83-
};
66+
it('should batch translate the input text', async function () {
67+
this.retries(3);
68+
const projectId = await translationClient.getProjectId();
69+
await clearBucket(projectId, storage, bucketUuid);
70+
const inputUri = 'gs://cloud-samples-data/translation/text.txt';
71+
72+
const outputUri = `gs://${projectId}/${bucketName}`;
73+
const output = execSync(
74+
`node v3/${REGION_TAG}.js ${projectId} ${location} ${inputUri} ${outputUri}`
75+
);
76+
assert.match(output, /Total Characters: 13/);
77+
assert.match(output, /Translated Characters: 13/);
78+
});
79+
// Delete the folder from GCS for cleanup
80+
after(async () => {
81+
const projectId = await translationClient.getProjectId();
82+
const options = {
83+
prefix: `translation-${bucketUuid}`,
84+
};
8485

85-
const bucket = await storage.bucket(projectId);
86-
const [files] = await bucket.getFiles(options);
87-
const length = files.length;
88-
if (length > 0) {
89-
await Promise.all(files.map(file => file.delete()));
90-
}
91-
});
86+
const bucket = await storage.bucket(projectId);
87+
await bucket.deleteFiles(options);
88+
});
9289
});

0 commit comments

Comments
 (0)