File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -170,6 +170,10 @@ Metadata.prototype.getDefaultResource = function(callback) {
170170 * @param {function } callback - The callback function.
171171 */
172172Metadata . prototype . getProjectId = function ( callback ) {
173+ if ( global . GCLOUD_SANDBOX_ENV ) {
174+ return ;
175+ }
176+
173177 var self = this ;
174178
175179 if ( this . logging_ . projectId ) {
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments