Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GCF tests #2399

Merged
merged 3 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion functions/helloworld/test/sample.system.http.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const Supertest = require('supertest');
const supertest = Supertest(process.env.BASE_URL);
const childProcess = require('child_process');

if (!process.env.GCF_REGION) {
throw new Error('"GCF_REGION" env var must be set.');
}

describe('system tests', () => {
// [END functions_http_system_test]
before(() => {
Expand All @@ -28,7 +32,7 @@ describe('system tests', () => {

after(() => {
childProcess.execSync(
`gcloud functions delete helloHttp --region=${process.env.GCF_REGION}`
`gcloud functions delete helloHttp --region=${process.env.GCF_REGION} --quiet`
);
});
// [START functions_http_system_test]
Expand Down
6 changes: 5 additions & 1 deletion functions/helloworld/test/sample.system.pubsub.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const promiseRetry = require('promise-retry');

const pubsub = new PubSub();
const topicName = process.env.FUNCTIONS_TOPIC;
if (!topicName) throw new Error('"FUNCTION_TOPIC" env var must be set.');
if (!process.env.GCF_REGION) {
throw new Error('"GCF_REGION" env var must be set.');
}
const baseCmd = 'gcloud functions';

describe('system tests', () => {
Expand All @@ -34,7 +38,7 @@ describe('system tests', () => {

after(() => {
childProcess.execSync(
`gcloud functions delete helloPubSub --region=${process.env.GCF_REGION}`
`gcloud functions delete helloPubSub --region=${process.env.GCF_REGION} --quiet`
);
});
// [START functions_pubsub_system_test]
Expand Down
8 changes: 7 additions & 1 deletion functions/helloworld/test/sample.system.storage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ const gcsFileName = `test-${uuid.v4()}.txt`;

const localFileName = 'test.txt';
const bucketName = process.env.FUNCTIONS_DELETABLE_BUCKET;
if (!bucketName) {
throw new Error('"FUNCTION_DELETABLE_BUCKET" env var must be set.');
}
if (!process.env.GCF_REGION) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should this be its own variable, since it's used in multiple places?

(If so, apply this comment throughout your PR.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving for a future update...

throw new Error('"GCF_REGION" env var must be set.');
}
const bucket = storage.bucket(bucketName);
const baseCmd = 'gcloud functions';

Expand All @@ -40,7 +46,7 @@ describe('system tests', () => {

after(() => {
childProcess.execSync(
`gcloud functions delete helloGCS --region=${process.env.GCF_REGION}`
`gcloud functions delete helloGCS --region=${process.env.GCF_REGION} --quiet`
);
});
// [START functions_storage_system_test]
Expand Down