GeezerVison is showing github.com — add system test running capabilities (#1592) · googleapis/google-cloud-node@a3bbe26
File tree
Expand file treeCollapse file tree
Open diff view settings
handwritten/bigquery/system-test
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: handwritten/bigquery/system-test/env.js +18-8Lines changed: 18 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
16 | 16 |
|
17 | 17 | 'use strict'; |
18 | 18 |
|
19 | | -if (!process.env.GCLOUD_TESTS_PROJECT_ID && !process.env.GCLOUD_TESTS_KEY) { |
20 | | - var error = [ |
| 19 | +var googleCloudConfig = {}; |
| 20 | + |
| 21 | +if (!process.env.GCLOUD_TESTS_CREDENTIALS && |
| 22 | + !process.env.GCLOUD_TESTS_PROJECT_ID && |
| 23 | + !process.env.GCLOUD_TESTS_KEY) { |
| 24 | + throw new Error([ |
21 | 25 | 'To run the system tests, you need to set some environment variables.', |
22 | 26 | 'Please check the Contributing guide for instructions.' |
23 | | - ].join('\n'); |
24 | | - throw error; |
| 27 | + ].join('\n')); |
| 28 | +} |
| 29 | + |
| 30 | +var credentials = process.env.GCLOUD_TESTS_CREDENTIALS; |
| 31 | + |
| 32 | +if (credentials) { |
| 33 | + googleCloudConfig.credentials = JSON.parse(credentials); |
| 34 | + googleCloudConfig.projectId = credentials.project_id; |
| 35 | +} else { |
| 36 | + googleCloudConfig.projectId = process.env.GCLOUD_TESTS_PROJECT_ID; |
| 37 | + googleCloudConfig.keyFilename = process.env.GCLOUD_TESTS_KEY; |
25 | 38 | } |
26 | 39 |
|
27 | | -module.exports = { |
28 | | - keyFilename: process.env.GCLOUD_TESTS_KEY, |
29 | | - projectId: process.env.GCLOUD_TESTS_PROJECT_ID |
30 | | -}; |
| 40 | +module.exports = googleCloudConfig; |