@@ -37,7 +37,6 @@ const fakePfy = extend({}, pfy, {
3737 promisified = true ;
3838 assert . deepStrictEqual ( options . exclude , [
3939 'delete' ,
40- 'getMetadata' ,
4140 'partitionedDml' ,
4241 'snapshot' ,
4342 'transaction' ,
@@ -285,10 +284,35 @@ describe('Session', () => {
285284 } ) ;
286285
287286 describe ( 'getMetadata' , ( ) => {
288- it ( 'should correctly call and return the request' , ( ) => {
287+ it ( 'should correctly call and return the request using callback ' , done => {
289288 const requestReturnValue = { } ;
290289
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 = { } ;
292316
293317 session . request = config => {
294318 assert . strictEqual ( config . client , 'SpannerClient' ) ;
@@ -304,10 +328,10 @@ describe('Session', () => {
304328 session . resourceHeader_
305329 )
306330 ) ;
307- return requestReturnValue ;
331+ return new Promise ( resolve => resolve ( requestReturnValue ) ) ;
308332 } ;
309333
310- const returnValue = session . getMetadata ( callback ) ;
334+ const returnValue = await session . getMetadata ( ) ;
311335 assert . strictEqual ( returnValue , requestReturnValue ) ;
312336 } ) ;
313337
0 commit comments