1616'use strict' ;
1717var assert = require ( 'assert' ) ;
1818var nock = require ( 'nock' ) ;
19- var path = require ( 'path' ) ;
2019var proxyquire = require ( 'proxyquire' ) ;
2120
2221describe ( 'common/metadata' , function ( ) {
@@ -62,7 +61,7 @@ describe('common/metadata', function() {
6261 done ( ) ;
6362 } ) ;
6463 } ) ;
65-
64+
6665 it ( 'should be able handle 500\'s from the service' ,
6766 function ( done ) {
6867 var scope = nock ( 'http://metadata.google.internal' )
@@ -83,26 +82,26 @@ describe('common/metadata', function() {
8382 it ( 'should accept an optional headers parameter' , function ( done ) {
8483 var scope =
8584 nock ( 'http://metadata.google.internal' , {
86- reqheaders : { ' Flux' : 'Capacitor' }
85+ reqheaders : { Flux : 'Capacitor' }
8786 } )
8887 . get ( '/computeMetadata/v1/project/project-id' )
8988 . reply ( 200 , 'a-stub-project-id' ) ;
90- metadata . getProjectId ( { ' Flux' : 'Capacitor' } , function ( err , project ) {
89+ metadata . getProjectId ( { Flux : 'Capacitor' } , function ( err , project ) {
9190 assert . ok ( ! err ) ;
9291 assert . strictEqual ( project , 'a-stub-project-id' ) ;
9392 scope . done ( ) ;
9493 done ( ) ;
9594 } ) ;
9695 } ) ;
9796
98- it ( 'Should callback with ENOTFOUND' , function ( done ) {
97+ it ( 'should callback with ENOTFOUND' , function ( done ) {
9998 var oldEnv = process . env . GCLOUD_PROJECT ;
10099 process . env . GCLOUD_PROJECT = './this-should-not-exist.json' ;
101100 var scope = nock ( 'http://metadata.google.internal' )
102101 . get ( '/computeMetadata/v1/project/project-id' )
103102 . once ( )
104- . replyWithError ( { ' message' : 'Not Found' , code : 'ENOTFOUND' } ) ;
105- metadata . getProjectId ( function ( e , result ) {
103+ . replyWithError ( { message : 'Not Found' , code : 'ENOTFOUND' } ) ;
104+ metadata . getProjectId ( function ( e , result ) {
106105 assert . ok ( e instanceof Error , 'e should be an instance of Error' ) ;
107106 assert . deepEqual ( result , null ) ;
108107 process . env . GCLOUD_PROJECT = oldEnv ;
@@ -114,30 +113,29 @@ describe('common/metadata', function() {
114113
115114 describe ( 'getInstanceId - valid cases' , function ( ) {
116115 var STUB_ID = 'a-stub-instance-id' ;
117- it (
118- 'Should be able to get the instance id without additional headers supplied',
119- function ( done ) {
116+ it ( 'should be able to get the instance id without additional headers ' +
117+ ' supplied',
118+ function ( done ) {
120119 var mock = nock ( 'http://metadata.google.internal/computeMetadata/v1' )
121120 . get ( '/instance/id' )
122121 . once ( )
123122 . reply ( 200 , STUB_ID ) ;
124- metadata . getInstanceId ( function ( err , id ) {
123+ metadata . getInstanceId ( function ( err , id ) {
125124 assert . deepEqual ( err , null , 'Error should be null' ) ;
126125 assert . deepEqual ( STUB_ID , id , 'The id should be the stub id' ) ;
127126 mock . done ( ) ;
128127 done ( ) ;
129128 } ) ;
130129 }
131130 ) ;
132- it (
133- 'Should be able to get the instance id with additional headers supplied' ,
134- function ( done ) {
131+ it ( 'should be able to get the instance id with additional headers supplied' ,
132+ function ( done ) {
135133 var mock = nock ( 'http://metadata.google.internal/computeMetadata/v1' ,
136134 { reqHeaders : { 'x-custom-header' : 'true' } } )
137135 . get ( '/instance/id' )
138136 . once ( )
139137 . reply ( 200 , STUB_ID ) ;
140- metadata . getInstanceId ( { 'x-custom-header' : 'true' } , function ( err , id ) {
138+ metadata . getInstanceId ( { 'x-custom-header' : 'true' } , function ( err , id ) {
141139 assert . deepEqual ( err , null , 'Error should be null' ) ;
142140 assert . deepEqual ( STUB_ID , id , 'The id should be the stub id' ) ;
143141 mock . done ( ) ;
@@ -149,14 +147,13 @@ describe('common/metadata', function() {
149147
150148 describe ( 'getHostname - valid cases' , function ( ) {
151149 var STUB_HOSTNAME = 'a-stub-hostname' ;
152- it (
153- 'Should be able to get the hostname without additional headers supplied' ,
154- function ( done ) {
150+ it ( 'should be able to get the hostname without additional headers supplied' ,
151+ function ( done ) {
155152 var mock = nock ( 'http://metadata.google.internal/computeMetadata/v1' )
156153 . get ( '/instance/hostname' )
157154 . once ( )
158155 . reply ( 200 , STUB_HOSTNAME ) ;
159- metadata . getHostname ( function ( err , id ) {
156+ metadata . getHostname ( function ( err , id ) {
160157 assert . deepEqual ( err , null , 'Error should be null' ) ;
161158 assert . deepEqual ( STUB_HOSTNAME , id ,
162159 'The hostname should be the stub hostname' ) ;
@@ -165,15 +162,14 @@ describe('common/metadata', function() {
165162 } ) ;
166163 }
167164 ) ;
168- it (
169- 'Should be able to get the hostname with additional headers supplied' ,
170- function ( done ) {
165+ it ( 'should be able to get the hostname with additional headers supplied' ,
166+ function ( done ) {
171167 var mock = nock ( 'http://metadata.google.internal/computeMetadata/v1' ,
172168 { reqHeaders : { 'x-custom-header' : 'true' } } )
173169 . get ( '/instance/hostname' )
174170 . once ( )
175171 . reply ( 200 , STUB_HOSTNAME ) ;
176- metadata . getHostname ( { 'x-custom-header' : 'true' } , function ( err , id ) {
172+ metadata . getHostname ( { 'x-custom-header' : 'true' } , function ( err , id ) {
177173 assert . deepEqual ( err , null , 'Error should be null' ) ;
178174 assert . deepEqual ( STUB_HOSTNAME , id ,
179175 'The hostname should be the stub hostname' ) ;
0 commit comments