From d637f34612a06ddca3965202d71f4c43e60aba22 Mon Sep 17 00:00:00 2001 From: averikitsch Date: Fri, 29 Oct 2021 09:21:17 -0700 Subject: [PATCH 1/2] Update GCF tests --- functions/helloworld/test/sample.system.http.test.js | 4 +++- functions/helloworld/test/sample.system.pubsub.test.js | 4 +++- functions/helloworld/test/sample.system.storage.test.js | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/functions/helloworld/test/sample.system.http.test.js b/functions/helloworld/test/sample.system.http.test.js index 7926a6a66e..6db58f0b17 100644 --- a/functions/helloworld/test/sample.system.http.test.js +++ b/functions/helloworld/test/sample.system.http.test.js @@ -18,6 +18,8 @@ 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(() => { @@ -28,7 +30,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] diff --git a/functions/helloworld/test/sample.system.pubsub.test.js b/functions/helloworld/test/sample.system.pubsub.test.js index d0b435c34a..4aa15670af 100644 --- a/functions/helloworld/test/sample.system.pubsub.test.js +++ b/functions/helloworld/test/sample.system.pubsub.test.js @@ -22,6 +22,8 @@ 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', () => { @@ -34,7 +36,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] diff --git a/functions/helloworld/test/sample.system.storage.test.js b/functions/helloworld/test/sample.system.storage.test.js index e57729d1dc..ab6ff5b127 100644 --- a/functions/helloworld/test/sample.system.storage.test.js +++ b/functions/helloworld/test/sample.system.storage.test.js @@ -27,6 +27,8 @@ 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) throw new Error('"GCF_REGION" env var must be set.'); const bucket = storage.bucket(bucketName); const baseCmd = 'gcloud functions'; @@ -40,7 +42,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] From fdfb9d3e2b829094eac6da7808cfd93c8ba203f4 Mon Sep 17 00:00:00 2001 From: averikitsch Date: Fri, 29 Oct 2021 09:38:49 -0700 Subject: [PATCH 2/2] lint --- functions/helloworld/test/sample.system.http.test.js | 4 +++- functions/helloworld/test/sample.system.pubsub.test.js | 4 +++- functions/helloworld/test/sample.system.storage.test.js | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/functions/helloworld/test/sample.system.http.test.js b/functions/helloworld/test/sample.system.http.test.js index 6db58f0b17..91362e9984 100644 --- a/functions/helloworld/test/sample.system.http.test.js +++ b/functions/helloworld/test/sample.system.http.test.js @@ -18,7 +18,9 @@ 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.'); +if (!process.env.GCF_REGION) { + throw new Error('"GCF_REGION" env var must be set.'); +} describe('system tests', () => { // [END functions_http_system_test] diff --git a/functions/helloworld/test/sample.system.pubsub.test.js b/functions/helloworld/test/sample.system.pubsub.test.js index 4aa15670af..6ebc327db5 100644 --- a/functions/helloworld/test/sample.system.pubsub.test.js +++ b/functions/helloworld/test/sample.system.pubsub.test.js @@ -23,7 +23,9 @@ 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.'); +if (!process.env.GCF_REGION) { + throw new Error('"GCF_REGION" env var must be set.'); +} const baseCmd = 'gcloud functions'; describe('system tests', () => { diff --git a/functions/helloworld/test/sample.system.storage.test.js b/functions/helloworld/test/sample.system.storage.test.js index ab6ff5b127..49b1c82b3c 100644 --- a/functions/helloworld/test/sample.system.storage.test.js +++ b/functions/helloworld/test/sample.system.storage.test.js @@ -27,8 +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) throw new Error('"GCF_REGION" env var must be set.'); +if (!bucketName) { + throw new Error('"FUNCTION_DELETABLE_BUCKET" env var must be set.'); +} +if (!process.env.GCF_REGION) { + throw new Error('"GCF_REGION" env var must be set.'); +} const bucket = storage.bucket(bucketName); const baseCmd = 'gcloud functions';