Skip to content

Commit 66f67b0

Browse files
fix snippet test
1 parent c045ede commit 66f67b0

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

packages/logging/src/metadata.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ Metadata.prototype.getDefaultResource = function(callback) {
170170
* @param {function} callback - The callback function.
171171
*/
172172
Metadata.prototype.getProjectId = function(callback) {
173+
if (global.GCLOUD_SANDBOX_ENV) {
174+
return;
175+
}
176+
173177
var self = this;
174178

175179
if (this.logging_.projectId) {

packages/logging/test/metadata.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ describe('metadata', function() {
320320
describe('getProjectId', function() {
321321
var CACHED_PROJECT_ID = 'cached-project-id';
322322

323+
it('should exit early if in the sandbox environment', function() {
324+
global.GCLOUD_SANDBOX_ENV = true;
325+
assert.strictEqual(metadata.getProjectId(), undefined);
326+
global.GCLOUD_SANDBOX_ENV = false;
327+
});
328+
323329
it('should return cached projectId from Logging instance', function(done) {
324330
metadata.logging_.projectId = CACHED_PROJECT_ID;
325331

0 commit comments

Comments
 (0)