import * as protos from '../protos/protos' ; import * as assert from 'assert' ; import * as sinon from 'sinon' ; import { SinonStub } from 'sinon' ; import { describe , it , beforeEach , afterEach } from 'mocha' ; import * as instancesModule from '../src' ; import { PassThrough } from 'stream' ; import { GoogleAuth , protobuf } from 'google-gax' ; function generateSampleMessage < T extends object > ( instance ) { const filledObject = ( instance . constructor as typeof protobuf . Message ) . toObject ( instance as protobuf . Message < T > , { defaults : true } ) ; return ( instance . constructor as typeof protobuf . Message ) . fromObject ( filledObject ) as T ; } function stubSimpleCall < ResponseType > ( response ? , error ? ) { return error ? sinon . stub ( ) . rejects ( error ) : sinon . stub ( ) . resolves ( [ response ] ) ; } function stubSimpleCallWithCallback < ResponseType > ( response ? , error ? ) { return error ? sinon . stub ( ) . callsArgWith ( 2 , error ) : sinon . stub ( ) . callsArgWith ( 2 , null , response ) ; } function stubPageStreamingCall < ResponseType > ( responses ? , error ? ) { const pagingStub = sinon . stub ( ) ; if ( responses ) { for ( let i = 0 ; i < responses . length ; ++ i ) { pagingStub . onCall ( i ) . callsArgWith ( 2 , null , responses [ i ] ) ; } } const transformStub = error ? sinon . stub ( ) . callsArgWith ( 2 , error ) : pagingStub ; const mockStream = new PassThrough ( { objectMode : true , transform : transformStub , } ) ; if ( responses ) { for ( let i = 0 ; i < responses . length ; ++ i ) { setImmediate ( ( ) => { mockStream . write ( { } ) ; } ) ; } setImmediate ( ( ) => { mockStream . end ( ) ; } ) ; } else { setImmediate ( ( ) => { mockStream . write ( { } ) ; } ) ; setImmediate ( ( ) => { mockStream . end ( ) ; } ) ; } return sinon . stub ( ) . returns ( mockStream ) ; } function stubAsyncIterationCall < ResponseType > ( responses ? , error ? ) { let counter = 0 ; const asyncIterable = { [ Symbol . asyncIterator ] ( ) { return { async next ( ) { if ( error ) { return Promise . reject ( error ) ; } if ( counter >= responses ! . length ) { return Promise . resolve ( { done : true , value : undefined } ) ; } return Promise . resolve ( { done : false , value : responses ! [ counter ++ ] } ) ; } , } ; } , } ; return sinon . stub ( ) . returns ( asyncIterable ) ; } describe ( 'v1.InstancesClient' , ( ) => { let googleAuth ; beforeEach ( ( ) => { googleAuth = { getClient : sinon . stub ( ) . resolves ( { getRequestHeaders : sinon . stub ( ) . resolves ( { Authorization : 'Bearer SOME_TOKEN' } ) , } ) , } as unknown as GoogleAuth ; } ) ; afterEach ( ( ) => { sinon . restore ( ) ; } ) ; it ( 'has servicePath' , ( ) => { const servicePath = instancesModule . v1 . InstancesClient . servicePath ; assert ( servicePath ) ; } ) ; it ( 'has apiEndpoint' , ( ) => { const apiEndpoint = instancesModule . v1 . InstancesClient . apiEndpoint ; assert ( apiEndpoint ) ; } ) ; it ( 'has port' , ( ) => { const port = instancesModule . v1 . InstancesClient . port ; assert ( port ) ; assert ( typeof port === 'number' ) ; } ) ; it ( 'should create a client with no option' , ( ) => { const client = new instancesModule . v1 . InstancesClient ( ) ; assert ( client ) ; } ) ; it ( 'should create a client with gRPC fallback' , ( ) => { const client = new instancesModule . v1 . InstancesClient ( { fallback : true , } ) ; assert ( client ) ; } ) ; it ( 'has initialize method and supports deferred initialization' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; assert . strictEqual ( client . instancesStub , undefined ) ; await client . initialize ( ) ; assert ( client . instancesStub ) ; } ) ; it ( 'has close method' , ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . close ( ) ; } ) ; it ( 'has getProjectId method' , async ( ) => { const fakeProjectId = 'fake-project-id' ; const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . auth . getProjectId = sinon . stub ( ) . resolves ( fakeProjectId ) ; const result = await client . getProjectId ( ) ; assert . strictEqual ( result , fakeProjectId ) ; assert ( ( client . auth . getProjectId as SinonStub ) . calledWithExactly ( ) ) ; } ) ; it ( 'has getProjectId method with callback' , async ( ) => { const fakeProjectId = 'fake-project-id' ; const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . auth . getProjectId = sinon . stub ( ) . callsArgWith ( 0 , null , fakeProjectId ) ; const promise = new Promise ( ( resolve , reject ) => { client . getProjectId ( ( err ? , projectId ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( projectId ) ; } } ) ; } ) ; const result = await promise ; assert . strictEqual ( result , fakeProjectId ) ; } ) ; describe ( 'addAccessConfig' , ( ) => { it ( 'invokes addAccessConfig without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . AddAccessConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . addAccessConfig = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . addAccessConfig ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . addAccessConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes addAccessConfig without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . AddAccessConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . addAccessConfig = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . addAccessConfig ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . addAccessConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes addAccessConfig with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . AddAccessConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . addAccessConfig = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . addAccessConfig ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . addAccessConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'addResourcePolicies' , ( ) => { it ( 'invokes addResourcePolicies without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . AddResourcePoliciesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . addResourcePolicies = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . addResourcePolicies ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . addResourcePolicies as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes addResourcePolicies without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . AddResourcePoliciesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . addResourcePolicies = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . addResourcePolicies ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . addResourcePolicies as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes addResourcePolicies with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . AddResourcePoliciesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . addResourcePolicies = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . addResourcePolicies ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . addResourcePolicies as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'attachDisk' , ( ) => { it ( 'invokes attachDisk without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . AttachDiskInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . attachDisk = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . attachDisk ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . attachDisk as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes attachDisk without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . AttachDiskInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . attachDisk = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . attachDisk ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . attachDisk as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes attachDisk with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . AttachDiskInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . attachDisk = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . attachDisk ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . attachDisk as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'bulkInsert' , ( ) => { it ( 'invokes bulkInsert without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . BulkInsertInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . bulkInsert = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . bulkInsert ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . bulkInsert as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes bulkInsert without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . BulkInsertInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . bulkInsert = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . bulkInsert ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . bulkInsert as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes bulkInsert with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . BulkInsertInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . bulkInsert = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . bulkInsert ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . bulkInsert as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'delete' , ( ) => { it ( 'invokes delete without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . DeleteInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . delete = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . delete ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . delete as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes delete without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . DeleteInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . delete = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . delete ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . delete as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes delete with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . DeleteInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . delete = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . delete ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . delete as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'deleteAccessConfig' , ( ) => { it ( 'invokes deleteAccessConfig without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . DeleteAccessConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . deleteAccessConfig = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . deleteAccessConfig ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . deleteAccessConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes deleteAccessConfig without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . DeleteAccessConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . deleteAccessConfig = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . deleteAccessConfig ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . deleteAccessConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes deleteAccessConfig with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . DeleteAccessConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . deleteAccessConfig = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . deleteAccessConfig ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . deleteAccessConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'detachDisk' , ( ) => { it ( 'invokes detachDisk without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . DetachDiskInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . detachDisk = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . detachDisk ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . detachDisk as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes detachDisk without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . DetachDiskInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . detachDisk = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . detachDisk ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . detachDisk as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes detachDisk with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . DetachDiskInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . detachDisk = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . detachDisk ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . detachDisk as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'get' , ( ) => { it ( 'invokes get without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) ; client . innerApiCalls . get = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . get ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . get as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes get without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) ; client . innerApiCalls . get = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . get ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . get as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes get with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . get = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . get ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . get as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'getEffectiveFirewalls' , ( ) => { it ( 'invokes getEffectiveFirewalls without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetEffectiveFirewallsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . InstancesGetEffectiveFirewallsResponse ( ) ) ; client . innerApiCalls . getEffectiveFirewalls = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . getEffectiveFirewalls ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getEffectiveFirewalls as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes getEffectiveFirewalls without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetEffectiveFirewallsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . InstancesGetEffectiveFirewallsResponse ( ) ) ; client . innerApiCalls . getEffectiveFirewalls = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . getEffectiveFirewalls ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getEffectiveFirewalls as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes getEffectiveFirewalls with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetEffectiveFirewallsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . getEffectiveFirewalls = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . getEffectiveFirewalls ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . getEffectiveFirewalls as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'getGuestAttributes' , ( ) => { it ( 'invokes getGuestAttributes without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetGuestAttributesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . GuestAttributes ( ) ) ; client . innerApiCalls . getGuestAttributes = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . getGuestAttributes ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getGuestAttributes as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes getGuestAttributes without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetGuestAttributesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . GuestAttributes ( ) ) ; client . innerApiCalls . getGuestAttributes = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . getGuestAttributes ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getGuestAttributes as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes getGuestAttributes with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetGuestAttributesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . getGuestAttributes = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . getGuestAttributes ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . getGuestAttributes as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'getIamPolicy' , ( ) => { it ( 'invokes getIamPolicy without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetIamPolicyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Policy ( ) ) ; client . innerApiCalls . getIamPolicy = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . getIamPolicy ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getIamPolicy as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes getIamPolicy without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetIamPolicyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Policy ( ) ) ; client . innerApiCalls . getIamPolicy = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . getIamPolicy ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getIamPolicy as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes getIamPolicy with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetIamPolicyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . getIamPolicy = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . getIamPolicy ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . getIamPolicy as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'getScreenshot' , ( ) => { it ( 'invokes getScreenshot without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetScreenshotInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Screenshot ( ) ) ; client . innerApiCalls . getScreenshot = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . getScreenshot ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getScreenshot as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes getScreenshot without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetScreenshotInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Screenshot ( ) ) ; client . innerApiCalls . getScreenshot = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . getScreenshot ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getScreenshot as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes getScreenshot with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetScreenshotInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . getScreenshot = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . getScreenshot ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . getScreenshot as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'getSerialPortOutput' , ( ) => { it ( 'invokes getSerialPortOutput without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetSerialPortOutputInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . SerialPortOutput ( ) ) ; client . innerApiCalls . getSerialPortOutput = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . getSerialPortOutput ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getSerialPortOutput as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes getSerialPortOutput without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetSerialPortOutputInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . SerialPortOutput ( ) ) ; client . innerApiCalls . getSerialPortOutput = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . getSerialPortOutput ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getSerialPortOutput as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes getSerialPortOutput with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetSerialPortOutputInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . getSerialPortOutput = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . getSerialPortOutput ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . getSerialPortOutput as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'getShieldedInstanceIdentity' , ( ) => { it ( 'invokes getShieldedInstanceIdentity without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetShieldedInstanceIdentityInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . ShieldedInstanceIdentity ( ) ) ; client . innerApiCalls . getShieldedInstanceIdentity = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . getShieldedInstanceIdentity ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getShieldedInstanceIdentity as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes getShieldedInstanceIdentity without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetShieldedInstanceIdentityInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . ShieldedInstanceIdentity ( ) ) ; client . innerApiCalls . getShieldedInstanceIdentity = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . getShieldedInstanceIdentity ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . getShieldedInstanceIdentity as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes getShieldedInstanceIdentity with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . GetShieldedInstanceIdentityInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . getShieldedInstanceIdentity = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . getShieldedInstanceIdentity ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . getShieldedInstanceIdentity as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'insert' , ( ) => { it ( 'invokes insert without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . InsertInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . insert = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . insert ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . insert as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes insert without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . InsertInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . insert = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . insert ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . insert as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes insert with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . InsertInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . insert = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . insert ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . insert as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'removeResourcePolicies' , ( ) => { it ( 'invokes removeResourcePolicies without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . RemoveResourcePoliciesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . removeResourcePolicies = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . removeResourcePolicies ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . removeResourcePolicies as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes removeResourcePolicies without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . RemoveResourcePoliciesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . removeResourcePolicies = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . removeResourcePolicies ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . removeResourcePolicies as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes removeResourcePolicies with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . RemoveResourcePoliciesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . removeResourcePolicies = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . removeResourcePolicies ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . removeResourcePolicies as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'reset' , ( ) => { it ( 'invokes reset without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ResetInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . reset = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . reset ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . reset as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes reset without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ResetInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . reset = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . reset ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . reset as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes reset with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ResetInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . reset = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . reset ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . reset as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'sendDiagnosticInterrupt' , ( ) => { it ( 'invokes sendDiagnosticInterrupt without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SendDiagnosticInterruptInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . SendDiagnosticInterruptInstanceResponse ( ) ) ; client . innerApiCalls . sendDiagnosticInterrupt = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . sendDiagnosticInterrupt ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . sendDiagnosticInterrupt as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes sendDiagnosticInterrupt without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SendDiagnosticInterruptInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . SendDiagnosticInterruptInstanceResponse ( ) ) ; client . innerApiCalls . sendDiagnosticInterrupt = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . sendDiagnosticInterrupt ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . sendDiagnosticInterrupt as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes sendDiagnosticInterrupt with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SendDiagnosticInterruptInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . sendDiagnosticInterrupt = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . sendDiagnosticInterrupt ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . sendDiagnosticInterrupt as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setDeletionProtection' , ( ) => { it ( 'invokes setDeletionProtection without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetDeletionProtectionInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setDeletionProtection = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setDeletionProtection ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . setDeletionProtection as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setDeletionProtection without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetDeletionProtectionInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setDeletionProtection = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setDeletionProtection ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setDeletionProtection as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setDeletionProtection with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetDeletionProtectionInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setDeletionProtection = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setDeletionProtection ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setDeletionProtection as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setDiskAutoDelete' , ( ) => { it ( 'invokes setDiskAutoDelete without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetDiskAutoDeleteInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setDiskAutoDelete = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setDiskAutoDelete ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . setDiskAutoDelete as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setDiskAutoDelete without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetDiskAutoDeleteInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setDiskAutoDelete = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setDiskAutoDelete ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setDiskAutoDelete as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setDiskAutoDelete with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetDiskAutoDeleteInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setDiskAutoDelete = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setDiskAutoDelete ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setDiskAutoDelete as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setIamPolicy' , ( ) => { it ( 'invokes setIamPolicy without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetIamPolicyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Policy ( ) ) ; client . innerApiCalls . setIamPolicy = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setIamPolicy ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setIamPolicy as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setIamPolicy without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetIamPolicyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Policy ( ) ) ; client . innerApiCalls . setIamPolicy = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setIamPolicy ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setIamPolicy as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setIamPolicy with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetIamPolicyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setIamPolicy = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setIamPolicy ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setIamPolicy as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setLabels' , ( ) => { it ( 'invokes setLabels without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetLabelsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setLabels = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setLabels ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . setLabels as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setLabels without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetLabelsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setLabels = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setLabels ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setLabels as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setLabels with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetLabelsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setLabels = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setLabels ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setLabels as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setMachineResources' , ( ) => { it ( 'invokes setMachineResources without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMachineResourcesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setMachineResources = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setMachineResources ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . setMachineResources as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setMachineResources without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMachineResourcesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setMachineResources = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setMachineResources ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setMachineResources as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setMachineResources with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMachineResourcesInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setMachineResources = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setMachineResources ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setMachineResources as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setMachineType' , ( ) => { it ( 'invokes setMachineType without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMachineTypeInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setMachineType = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setMachineType ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . setMachineType as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setMachineType without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMachineTypeInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setMachineType = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setMachineType ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setMachineType as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setMachineType with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMachineTypeInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setMachineType = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setMachineType ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setMachineType as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setMetadata' , ( ) => { it ( 'invokes setMetadata without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMetadataInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setMetadata = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setMetadata ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . setMetadata as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setMetadata without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMetadataInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setMetadata = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setMetadata ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setMetadata as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setMetadata with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMetadataInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setMetadata = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setMetadata ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setMetadata as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setMinCpuPlatform' , ( ) => { it ( 'invokes setMinCpuPlatform without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMinCpuPlatformInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setMinCpuPlatform = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setMinCpuPlatform ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . setMinCpuPlatform as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setMinCpuPlatform without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMinCpuPlatformInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setMinCpuPlatform = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setMinCpuPlatform ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setMinCpuPlatform as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setMinCpuPlatform with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetMinCpuPlatformInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setMinCpuPlatform = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setMinCpuPlatform ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setMinCpuPlatform as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setScheduling' , ( ) => { it ( 'invokes setScheduling without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetSchedulingInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setScheduling = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setScheduling ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . setScheduling as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setScheduling without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetSchedulingInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setScheduling = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setScheduling ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setScheduling as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setScheduling with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetSchedulingInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setScheduling = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setScheduling ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setScheduling as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setServiceAccount' , ( ) => { it ( 'invokes setServiceAccount without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetServiceAccountInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setServiceAccount = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setServiceAccount ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . setServiceAccount as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setServiceAccount without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetServiceAccountInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setServiceAccount = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setServiceAccount ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setServiceAccount as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setServiceAccount with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetServiceAccountInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setServiceAccount = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setServiceAccount ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setServiceAccount as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setShieldedInstanceIntegrityPolicy' , ( ) => { it ( 'invokes setShieldedInstanceIntegrityPolicy without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetShieldedInstanceIntegrityPolicyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setShieldedInstanceIntegrityPolicy = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setShieldedInstanceIntegrityPolicy ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . setShieldedInstanceIntegrityPolicy as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setShieldedInstanceIntegrityPolicy without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetShieldedInstanceIntegrityPolicyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setShieldedInstanceIntegrityPolicy = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setShieldedInstanceIntegrityPolicy ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setShieldedInstanceIntegrityPolicy as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setShieldedInstanceIntegrityPolicy with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetShieldedInstanceIntegrityPolicyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setShieldedInstanceIntegrityPolicy = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setShieldedInstanceIntegrityPolicy ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setShieldedInstanceIntegrityPolicy as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'setTags' , ( ) => { it ( 'invokes setTags without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetTagsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setTags = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . setTags ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . setTags as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes setTags without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetTagsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . setTags = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . setTags ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . setTags as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes setTags with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SetTagsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . setTags = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . setTags ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . setTags as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'simulateMaintenanceEvent' , ( ) => { it ( 'invokes simulateMaintenanceEvent without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SimulateMaintenanceEventInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . simulateMaintenanceEvent = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . simulateMaintenanceEvent ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . simulateMaintenanceEvent as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes simulateMaintenanceEvent without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SimulateMaintenanceEventInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . simulateMaintenanceEvent = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . simulateMaintenanceEvent ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . simulateMaintenanceEvent as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes simulateMaintenanceEvent with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . SimulateMaintenanceEventInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . simulateMaintenanceEvent = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . simulateMaintenanceEvent ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . simulateMaintenanceEvent as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'start' , ( ) => { it ( 'invokes start without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . StartInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . start = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . start ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . start as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes start without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . StartInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . start = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . start ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . start as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes start with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . StartInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . start = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . start ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . start as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'startWithEncryptionKey' , ( ) => { it ( 'invokes startWithEncryptionKey without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . StartWithEncryptionKeyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . startWithEncryptionKey = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . startWithEncryptionKey ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . startWithEncryptionKey as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes startWithEncryptionKey without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . StartWithEncryptionKeyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . startWithEncryptionKey = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . startWithEncryptionKey ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . startWithEncryptionKey as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes startWithEncryptionKey with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . StartWithEncryptionKeyInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . startWithEncryptionKey = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . startWithEncryptionKey ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . startWithEncryptionKey as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'stop' , ( ) => { it ( 'invokes stop without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . StopInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . stop = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . stop ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . stop as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes stop without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . StopInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . stop = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . stop ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . stop as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes stop with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . StopInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . stop = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . stop ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . stop as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'testIamPermissions' , ( ) => { it ( 'invokes testIamPermissions without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . TestIamPermissionsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . TestPermissionsResponse ( ) ) ; client . innerApiCalls . testIamPermissions = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . testIamPermissions ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . testIamPermissions as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes testIamPermissions without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . TestIamPermissionsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . TestPermissionsResponse ( ) ) ; client . innerApiCalls . testIamPermissions = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . testIamPermissions ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . testIamPermissions as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes testIamPermissions with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . TestIamPermissionsInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . testIamPermissions = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . testIamPermissions ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . testIamPermissions as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'update' , ( ) => { it ( 'invokes update without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . update = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . update ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . update as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes update without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . update = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . update ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . update as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes update with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . update = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . update ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . update as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'updateAccessConfig' , ( ) => { it ( 'invokes updateAccessConfig without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateAccessConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . updateAccessConfig = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . updateAccessConfig ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . updateAccessConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes updateAccessConfig without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateAccessConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . updateAccessConfig = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . updateAccessConfig ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . updateAccessConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes updateAccessConfig with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateAccessConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . updateAccessConfig = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . updateAccessConfig ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . updateAccessConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'updateDisplayDevice' , ( ) => { it ( 'invokes updateDisplayDevice without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateDisplayDeviceInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . updateDisplayDevice = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . updateDisplayDevice ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . updateDisplayDevice as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes updateDisplayDevice without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateDisplayDeviceInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . updateDisplayDevice = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . updateDisplayDevice ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . updateDisplayDevice as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes updateDisplayDevice with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateDisplayDeviceInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . updateDisplayDevice = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . updateDisplayDevice ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . updateDisplayDevice as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'updateNetworkInterface' , ( ) => { it ( 'invokes updateNetworkInterface without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateNetworkInterfaceInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . updateNetworkInterface = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . updateNetworkInterface ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . updateNetworkInterface as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes updateNetworkInterface without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateNetworkInterfaceInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . updateNetworkInterface = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . updateNetworkInterface ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . updateNetworkInterface as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes updateNetworkInterface with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateNetworkInterfaceInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . updateNetworkInterface = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . updateNetworkInterface ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . updateNetworkInterface as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'updateShieldedInstanceConfig' , ( ) => { it ( 'invokes updateShieldedInstanceConfig without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateShieldedInstanceConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . updateShieldedInstanceConfig = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . updateShieldedInstanceConfig ( request ) ; assert . deepStrictEqual ( response . latestResponse , expectedResponse ) ; assert ( ( client . innerApiCalls . updateShieldedInstanceConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes updateShieldedInstanceConfig without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateShieldedInstanceConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = generateSampleMessage ( new protos . google . cloud . compute . v1 . Operation ( ) ) ; client . innerApiCalls . updateShieldedInstanceConfig = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . updateShieldedInstanceConfig ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . updateShieldedInstanceConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes updateShieldedInstanceConfig with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . UpdateShieldedInstanceConfigInstanceRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . updateShieldedInstanceConfig = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . updateShieldedInstanceConfig ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . updateShieldedInstanceConfig as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; } ) ; describe ( 'aggregatedList' , ( ) => { it ( 'uses async iteration with aggregatedList without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . AggregatedListInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedResponse = [ [ 'tuple_key_1' , generateSampleMessage ( new protos . google . cloud . compute . v1 . InstancesScopedList ( ) ) , ] , [ 'tuple_key_2' , generateSampleMessage ( new protos . google . cloud . compute . v1 . InstancesScopedList ( ) ) , ] , [ 'tuple_key_3' , generateSampleMessage ( new protos . google . cloud . compute . v1 . InstancesScopedList ( ) ) , ] , ] ; client . descriptors . page . aggregatedList . asyncIterate = stubAsyncIterationCall ( expectedResponse ) ; const responses = [ ] ; const iterable = client . aggregatedListAsync ( request ) ; for await ( const resource of iterable ) { responses . push ( resource ! ) ; } assert . deepStrictEqual ( responses , expectedResponse ) ; assert . deepStrictEqual ( ( client . descriptors . page . aggregatedList . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 1 ] , request ) ; assert . strictEqual ( ( client . descriptors . page . aggregatedList . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 2 ] . otherArgs . headers [ 'x-goog-request-params' ] , expectedHeaderRequestParams ) ; } ) ; it ( 'uses async iteration with aggregatedList with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . AggregatedListInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedError = new Error ( 'expected' ) ; client . descriptors . page . aggregatedList . asyncIterate = stubAsyncIterationCall ( undefined , expectedError ) ; const iterable = client . aggregatedListAsync ( request ) ; await assert . rejects ( async ( ) => { const responses = [ ] ; for await ( const resource of iterable ) { responses . push ( resource ! ) ; } } ) ; assert . deepStrictEqual ( ( client . descriptors . page . aggregatedList . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 1 ] , request ) ; assert . strictEqual ( ( client . descriptors . page . aggregatedList . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 2 ] . otherArgs . headers [ 'x-goog-request-params' ] , expectedHeaderRequestParams ) ; } ) ; } ) ; describe ( 'list' , ( ) => { it ( 'invokes list without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = [ generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , ] ; client . innerApiCalls . list = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . list ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . list as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes list without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = [ generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , ] ; client . innerApiCalls . list = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . list ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . list as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes list with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . list = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . list ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . list as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes listStream without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedResponse = [ generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , ] ; client . descriptors . page . list . createStream = stubPageStreamingCall ( expectedResponse ) ; const stream = client . listStream ( request ) ; const promise = new Promise ( ( resolve , reject ) => { const responses = [ ] ; stream . on ( 'data' , ( response ) => { responses . push ( response ) ; } ) ; stream . on ( 'end' , ( ) => { resolve ( responses ) ; } ) ; stream . on ( 'error' , ( err ) => { reject ( err ) ; } ) ; } ) ; const responses = await promise ; assert . deepStrictEqual ( responses , expectedResponse ) ; assert ( ( client . descriptors . page . list . createStream as SinonStub ) . getCall ( 0 ) . calledWith ( client . innerApiCalls . list , request ) ) ; assert . strictEqual ( ( client . descriptors . page . list . createStream as SinonStub ) . getCall ( 0 ) . args [ 2 ] . otherArgs . headers [ 'x-goog-request-params' ] , expectedHeaderRequestParams ) ; } ) ; it ( 'invokes listStream with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedError = new Error ( 'expected' ) ; client . descriptors . page . list . createStream = stubPageStreamingCall ( undefined , expectedError ) ; const stream = client . listStream ( request ) ; const promise = new Promise ( ( resolve , reject ) => { const responses = [ ] ; stream . on ( 'data' , ( response ) => { responses . push ( response ) ; } ) ; stream . on ( 'end' , ( ) => { resolve ( responses ) ; } ) ; stream . on ( 'error' , ( err ) => { reject ( err ) ; } ) ; } ) ; await assert . rejects ( promise , expectedError ) ; assert ( ( client . descriptors . page . list . createStream as SinonStub ) . getCall ( 0 ) . calledWith ( client . innerApiCalls . list , request ) ) ; assert . strictEqual ( ( client . descriptors . page . list . createStream as SinonStub ) . getCall ( 0 ) . args [ 2 ] . otherArgs . headers [ 'x-goog-request-params' ] , expectedHeaderRequestParams ) ; } ) ; it ( 'uses async iteration with list without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedResponse = [ generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Instance ( ) ) , ] ; client . descriptors . page . list . asyncIterate = stubAsyncIterationCall ( expectedResponse ) ; const responses = [ ] ; const iterable = client . listAsync ( request ) ; for await ( const resource of iterable ) { responses . push ( resource ! ) ; } assert . deepStrictEqual ( responses , expectedResponse ) ; assert . deepStrictEqual ( ( client . descriptors . page . list . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 1 ] , request ) ; assert . strictEqual ( ( client . descriptors . page . list . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 2 ] . otherArgs . headers [ 'x-goog-request-params' ] , expectedHeaderRequestParams ) ; } ) ; it ( 'uses async iteration with list with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedError = new Error ( 'expected' ) ; client . descriptors . page . list . asyncIterate = stubAsyncIterationCall ( undefined , expectedError ) ; const iterable = client . listAsync ( request ) ; await assert . rejects ( async ( ) => { const responses = [ ] ; for await ( const resource of iterable ) { responses . push ( resource ! ) ; } } ) ; assert . deepStrictEqual ( ( client . descriptors . page . list . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 1 ] , request ) ; assert . strictEqual ( ( client . descriptors . page . list . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 2 ] . otherArgs . headers [ 'x-goog-request-params' ] , expectedHeaderRequestParams ) ; } ) ; } ) ; describe ( 'listReferrers' , ( ) => { it ( 'invokes listReferrers without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListReferrersInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = [ generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , ] ; client . innerApiCalls . listReferrers = stubSimpleCall ( expectedResponse ) ; const [ response ] = await client . listReferrers ( request ) ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . listReferrers as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes listReferrers without error using callback' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListReferrersInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedResponse = [ generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , ] ; client . innerApiCalls . listReferrers = stubSimpleCallWithCallback ( expectedResponse ) ; const promise = new Promise ( ( resolve , reject ) => { client . listReferrers ( request , ( err ? , result ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( result ) ; } } ) ; } ) ; const response = await promise ; assert . deepStrictEqual ( response , expectedResponse ) ; assert ( ( client . innerApiCalls . listReferrers as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions ) ) ; } ) ; it ( 'invokes listReferrers with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListReferrersInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedOptions = { otherArgs : { headers : { 'x-goog-request-params' : expectedHeaderRequestParams , } , } , } ; const expectedError = new Error ( 'expected' ) ; client . innerApiCalls . listReferrers = stubSimpleCall ( undefined , expectedError ) ; await assert . rejects ( client . listReferrers ( request ) , expectedError ) ; assert ( ( client . innerApiCalls . listReferrers as SinonStub ) . getCall ( 0 ) . calledWith ( request , expectedOptions , undefined ) ) ; } ) ; it ( 'invokes listReferrersStream without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListReferrersInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedResponse = [ generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , ] ; client . descriptors . page . listReferrers . createStream = stubPageStreamingCall ( expectedResponse ) ; const stream = client . listReferrersStream ( request ) ; const promise = new Promise ( ( resolve , reject ) => { const responses = [ ] ; stream . on ( 'data' , ( response ) => { responses . push ( response ) ; } ) ; stream . on ( 'end' , ( ) => { resolve ( responses ) ; } ) ; stream . on ( 'error' , ( err ) => { reject ( err ) ; } ) ; } ) ; const responses = await promise ; assert . deepStrictEqual ( responses , expectedResponse ) ; assert ( ( client . descriptors . page . listReferrers . createStream as SinonStub ) . getCall ( 0 ) . calledWith ( client . innerApiCalls . listReferrers , request ) ) ; assert . strictEqual ( ( client . descriptors . page . listReferrers . createStream as SinonStub ) . getCall ( 0 ) . args [ 2 ] . otherArgs . headers [ 'x-goog-request-params' ] , expectedHeaderRequestParams ) ; } ) ; it ( 'invokes listReferrersStream with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListReferrersInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedError = new Error ( 'expected' ) ; client . descriptors . page . listReferrers . createStream = stubPageStreamingCall ( undefined , expectedError ) ; const stream = client . listReferrersStream ( request ) ; const promise = new Promise ( ( resolve , reject ) => { const responses = [ ] ; stream . on ( 'data' , ( response ) => { responses . push ( response ) ; } ) ; stream . on ( 'end' , ( ) => { resolve ( responses ) ; } ) ; stream . on ( 'error' , ( err ) => { reject ( err ) ; } ) ; } ) ; await assert . rejects ( promise , expectedError ) ; assert ( ( client . descriptors . page . listReferrers . createStream as SinonStub ) . getCall ( 0 ) . calledWith ( client . innerApiCalls . listReferrers , request ) ) ; assert . strictEqual ( ( client . descriptors . page . listReferrers . createStream as SinonStub ) . getCall ( 0 ) . args [ 2 ] . otherArgs . headers [ 'x-goog-request-params' ] , expectedHeaderRequestParams ) ; } ) ; it ( 'uses async iteration with listReferrers without error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { auth : googleAuth , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListReferrersInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedResponse = [ generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , generateSampleMessage ( new protos . google . cloud . compute . v1 . Reference ( ) ) , ] ; client . descriptors . page . listReferrers . asyncIterate = stubAsyncIterationCall ( expectedResponse ) ; const responses = [ ] ; const iterable = client . listReferrersAsync ( request ) ; for await ( const resource of iterable ) { responses . push ( resource ! ) ; } assert . deepStrictEqual ( responses , expectedResponse ) ; assert . deepStrictEqual ( ( client . descriptors . page . listReferrers . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 1 ] , request ) ; assert . strictEqual ( ( client . descriptors . page . listReferrers . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 2 ] . otherArgs . headers [ 'x-goog-request-params' ] , expectedHeaderRequestParams ) ; } ) ; it ( 'uses async iteration with listReferrers with error' , async ( ) => { const client = new instancesModule . v1 . InstancesClient ( { credentials : { client_email : 'bogus' , private_key : 'bogus' } , projectId : 'bogus' , } ) ; client . initialize ( ) ; const request = generateSampleMessage ( new protos . google . cloud . compute . v1 . ListReferrersInstancesRequest ( ) ) ; request . project = '' ; const expectedHeaderRequestParams = 'project=' ; const expectedError = new Error ( 'expected' ) ; client . descriptors . page . listReferrers . asyncIterate = stubAsyncIterationCall ( undefined , expectedError ) ; const iterable = client . listReferrersAsync ( request ) ; await assert . rejects ( async ( ) => { const responses = [ ] ; for await ( const resource of iterable ) { responses . push ( resource ! ) ; } } ) ; assert . deepStrictEqual ( ( client . descriptors . page . listReferrers . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 1 ] , request ) ; assert . strictEqual ( ( client . descriptors . page . listReferrers . asyncIterate as SinonStub ) . getCall ( 0 ) . args [ 2 ] . otherArgs . headers [ 'x-goog-request-params' ] , expectedHeaderRequestParams ) ; } ) ; } ) ; } ) ;