@@ -119,158 +119,6 @@ describe('Debuglet', () => {
119119 } ) ;
120120 } ) ;
121121
122- describe ( 'runningOnGCP' , ( ) => {
123- // TODO: Make this more precise.
124- let savedLookup : Function ;
125- before ( ( ) => {
126- savedLookup = dns . lookup ;
127- } ) ;
128-
129- after ( ( ) => {
130- // TODO: Fix this cast to any that is caused by the fact that `lookup`
131- // is a readonly property.
132- ( dns as { lookup : { } } ) . lookup = savedLookup ;
133- } ) ;
134-
135- it ( 'should resolve true if metadata service is resolveable' , ( done ) => {
136- // TODO: Fix this cast to any that is caused by the fact that `lookup`
137- // is a readonly property.
138- // TODO: Determine if the hostname parameter should be used.
139- ( dns as { lookup : { } } ) . lookup =
140- ( hostname : string | null ,
141- cb : ( err : Error | null , param : { address : string , family : string } ) =>
142- void ) => {
143- setImmediate ( ( ) => {
144- cb ( null , { address : '700.800.900.fake' , family : 'Addams' } ) ;
145- } ) ;
146- } ;
147-
148- Debuglet . runningOnGCP ( ) . then ( ( onGCP ) => {
149- assert . strictEqual ( onGCP , true ) ;
150- done ( ) ;
151- } ) ;
152- } ) ;
153-
154- it ( 'should resolve false if metadata service not resolveable' , ( done ) => {
155- // TODO: Fix this cast to any that is caused by the fact that `lookup`
156- // is a readonly property.
157- // TODO: Determine if the hostname parameter should be used.
158- // TODO: Determine if these types are correct
159- ( dns as { lookup : { } } ) . lookup =
160- ( hostname : string , cb : ( err : Error ) => void ) => {
161- setImmediate ( ( ) => {
162- cb ( new Error ( 'resolution error' ) ) ;
163- } ) ;
164- } ;
165-
166- Debuglet . runningOnGCP ( ) . then ( ( onGCP ) => {
167- assert . strictEqual ( onGCP , false ) ;
168- done ( ) ;
169- } ) ;
170- } ) ;
171- } ) ;
172-
173- describe ( 'getProjectIdFromMetadata' , ( ) => {
174- let savedProject : Function ;
175- before ( ( ) => {
176- savedProject = metadata . project ;
177- } ) ;
178- after ( ( ) => {
179- metadata . project = savedProject ;
180- } ) ;
181-
182- it ( 'should return project retrived from metadata' , ( done ) => {
183- const FAKE_PROJECT_ID = 'fake-project-id-from-metadata' ;
184- // TODO: Determine if the options to Debug should be optional so that
185- // new Debug() can be used instead of new Debug({}).
186- // TODO: This is never used. Determine if it should be used.
187- // const debug = new Debug({});
188- // TODO: This is never used. Determine if it should be used.
189- // const debuglet = new Debuglet(debug, defaultConfig);
190-
191- // TODO: Determine if the path parameter should be used.
192- // TODO: Determine if these types are correct
193- metadata . project = ( instancePath : string , cb : MetadataCallback ) => {
194- setImmediate ( ( ) => {
195- cb ( null , { } , FAKE_PROJECT_ID ) ;
196- } ) ;
197- } ;
198-
199- Debuglet . getProjectIdFromMetadata ( ) . then ( ( projectId ) => {
200- assert . strictEqual ( projectId , FAKE_PROJECT_ID ) ;
201- done ( ) ;
202- } ) ;
203- } ) ;
204-
205- it ( 'should return null on error' , ( done ) => {
206- // TODO: This is never used. Determine if it should be used.
207- // const debug = new Debug({});
208- // TODO: This is never used. Determine if it should be used.
209- // const debuglet = new Debuglet(debug, defaultConfig);
210-
211- // TODO: Determine if the path parameter should be used.
212- metadata . project = ( instancePath : string , cb : MetadataCallback ) => {
213- setImmediate ( ( ) => {
214- cb ( new Error ( ) ) ;
215- } ) ;
216- } ;
217-
218- // TODO: Determine if the err parameter should be used.
219- Debuglet . getProjectIdFromMetadata ( ) . catch ( ( err ) => {
220- done ( ) ;
221- } ) ;
222- } ) ;
223- } ) ;
224-
225- describe ( 'getClusterNameFromMetadata' , ( ) => {
226- let savedInstance : Function ;
227- before ( ( ) => {
228- savedInstance = metadata . instance ;
229- } ) ;
230- after ( ( ) => {
231- metadata . instance = savedInstance ;
232- } ) ;
233-
234- it ( 'should return project retrived from metadata' , ( done ) => {
235- const FAKE_CLUSTER_NAME = 'fake-cluster-name-from-metadata' ;
236- // TODO: This is never used. Determine if it should be used.
237- // const debug = new Debug({});
238- // TODO: This is never used. Determine if it should be used.
239- // const debuglet = new Debuglet(debug, defaultConfig);
240-
241- // TODO: Determine if the path parameter should be used.
242- metadata . instance = ( instancePath : string , cb : MetadataCallback ) => {
243- setImmediate ( ( ) => {
244- cb ( null , { } , FAKE_CLUSTER_NAME ) ;
245- } ) ;
246- } ;
247-
248- Debuglet . getClusterNameFromMetadata ( ) . then ( ( clusterName ) => {
249- assert . strictEqual ( clusterName , FAKE_CLUSTER_NAME ) ;
250- done ( ) ;
251- } ) ;
252- } ) ;
253-
254- it ( 'should return null on error' , ( done ) => {
255- // TODO: This is never used. Determine if it should be used.
256- // const debug = new Debug({});
257- // TODO: This is never used. Determine if it should be used.
258- // const debuglet = new Debuglet(debug, defaultConfig);
259-
260- // TODO: Determine if the path parameter should be used.
261- metadata . instance = ( instancePath : string , cb : MetadataCallback ) => {
262- setImmediate ( ( ) => {
263- cb ( new Error ( ) ) ;
264- } ) ;
265- } ;
266-
267- // TODO: Determine if the err parameter should be used.
268- Debuglet . getClusterNameFromMetadata ( ) . catch ( ( err ) => {
269- done ( ) ;
270- } ) ;
271- } ) ;
272- } ) ;
273-
274122 describe ( 'getProjectId' , ( ) => {
275123 let savedGetProjectIdFromMetadata : ( ) => Promise < string > ;
276124
0 commit comments