@@ -37,7 +37,6 @@ const fakePfy = extend({}, pfy, {
37
37
promisified = true ;
38
38
assert . deepStrictEqual ( options . exclude , [
39
39
'delete' ,
40
- 'getMetadata' ,
41
40
'partitionedDml' ,
42
41
'snapshot' ,
43
42
'transaction' ,
@@ -285,10 +284,35 @@ describe('Session', () => {
285
284
} ) ;
286
285
287
286
describe ( 'getMetadata' , ( ) => {
288
- it ( 'should correctly call and return the request' , ( ) => {
287
+ it ( 'should correctly call and return the request using callback ' , done => {
289
288
const requestReturnValue = { } ;
290
289
291
- function callback ( ) { }
290
+ session . request = ( config , callback ) => {
291
+ assert . strictEqual ( config . client , 'SpannerClient' ) ;
292
+ assert . strictEqual ( config . method , 'getSession' ) ;
293
+ assert . deepStrictEqual ( config . reqOpts , {
294
+ name : session . formattedName_ ,
295
+ } ) ;
296
+ assert . deepStrictEqual ( config . gaxOpts , { } ) ;
297
+ assert . deepStrictEqual (
298
+ config . headers ,
299
+ Object . assign (
300
+ { [ LEADER_AWARE_ROUTING_HEADER ] : true } ,
301
+ session . resourceHeader_
302
+ )
303
+ ) ;
304
+ callback ( null , requestReturnValue ) ;
305
+ } ;
306
+
307
+ session . getMetadata ( ( err , returnValue ) => {
308
+ assert . ifError ( err ) ;
309
+ assert . strictEqual ( returnValue , requestReturnValue ) ;
310
+ done ( ) ;
311
+ } ) ;
312
+ } ) ;
313
+
314
+ it ( 'should correctly call and return the request using promise' , async ( ) => {
315
+ const requestReturnValue = { } ;
292
316
293
317
session . request = config => {
294
318
assert . strictEqual ( config . client , 'SpannerClient' ) ;
@@ -304,10 +328,10 @@ describe('Session', () => {
304
328
session . resourceHeader_
305
329
)
306
330
) ;
307
- return requestReturnValue ;
331
+ return new Promise ( resolve => resolve ( requestReturnValue ) ) ;
308
332
} ;
309
333
310
- const returnValue = session . getMetadata ( callback ) ;
334
+ const returnValue = await session . getMetadata ( ) ;
311
335
assert . strictEqual ( returnValue , requestReturnValue ) ;
312
336
} ) ;
313
337
0 commit comments