@@ -66,16 +66,19 @@ describe('AwsClientBuilderV3', function () {
6666 assert . strictEqual ( service . config . userAgent [ 0 ] [ 0 ] , 'CUSTOM USER AGENT' )
6767 } )
6868
69- it ( 'adds region to client' , async function ( ) {
70- const service = await builder . createAwsService ( Client , { region : 'us-west-2' } )
71- assert . ok ( service . config . region )
72- assert . strictEqual ( service . config . region , 'us-west-2' )
73- } )
74-
7569 describe ( 'middlewareStack' , function ( ) {
7670 let args : { request : { hostname : string ; path : string } ; input : any }
7771 let context : { clientName ?: string ; commandName ?: string }
7872 let response : { response : { statusCode : number } ; output : { message : string } }
73+ let httpRequestStub : sinon . SinonStub
74+ let httpResponseStub : sinon . SinonStub
75+
76+ before ( function ( ) {
77+ httpRequestStub = sinon . stub ( HttpRequest , 'isInstance' )
78+ httpResponseStub = sinon . stub ( HttpResponse , 'isInstance' )
79+ httpRequestStub . callsFake ( ( ) => true )
80+ httpResponseStub . callsFake ( ( ) => true )
81+ } )
7982
8083 beforeEach ( function ( ) {
8184 args = {
@@ -99,19 +102,16 @@ describe('AwsClientBuilderV3', function () {
99102 } ,
100103 }
101104 } )
102- afterEach ( function ( ) {
105+ after ( function ( ) {
103106 sinon . restore ( )
104107 } )
105108
106109 it ( 'logs messages on request' , async function ( ) {
107- sinon . stub ( HttpRequest , 'isInstance' ) . callsFake ( ( ) => true )
108110 await logOnRequest ( ( _ : any ) => _ , args as any )
109111 assertLogsContainAllOf ( [ 'testHost' , 'testPath' ] , false , 'debug' )
110112 } )
111113
112- it ( 'adds telemetry meta and logs on error failure' , async function ( ) {
113- sinon . stub ( HttpResponse , 'isInstance' ) . callsFake ( ( ) => true )
114-
114+ it ( 'adds telemetry metadata and logs on error failure' , async function ( ) {
115115 const next = ( _ : any ) => {
116116 throw new Error ( 'test error' )
117117 }
@@ -123,21 +123,19 @@ describe('AwsClientBuilderV3', function () {
123123 } )
124124
125125 it ( 'does not emit telemetry, but still logs on successes' , async function ( ) {
126- sinon . stub ( HttpResponse , 'isInstance' ) . callsFake ( ( ) => true )
127126 const next = async ( _ : any ) => {
128127 return response
129128 }
130129 await telemetry . vscode_executeCommand . run ( async ( span ) => {
131130 assert . deepStrictEqual ( await emitOnRequest ( next , context , args ) , response )
132131 } )
133132 assertLogsContainAllOf ( [ 'testHost' , 'testPath' ] , false , 'debug' )
134- assert . throws ( ( ) => assertTelemetry ( 'vscode_executeCommand' , { requestServiceType : 'test ' } ) )
133+ assert . throws ( ( ) => assertTelemetry ( 'vscode_executeCommand' , { requestServiceType : 'foo ' } ) )
135134 } )
136135
137136 it ( 'custom endpoints overwrite request url' , async function ( ) {
138137 const settings = new TestSettings ( )
139138 await settings . update ( 'aws.dev.endpoints' , { foo : 'http://example.com:3000/path' } )
140- sinon . stub ( HttpRequest , 'isInstance' ) . callsFake ( ( ) => true )
141139 const next = async ( args : any ) => args
142140 const newArgs : any = await overwriteEndpoint ( next , context , new DevSettings ( settings ) , args )
143141
@@ -149,7 +147,6 @@ describe('AwsClientBuilderV3', function () {
149147
150148 it ( 'custom endpoints are not overwritten if not specified' , async function ( ) {
151149 const settings = new TestSettings ( )
152- sinon . stub ( HttpRequest , 'isInstance' ) . callsFake ( ( ) => true )
153150 const next = async ( args : any ) => args
154151 const newArgs : any = await overwriteEndpoint ( next , context , new DevSettings ( settings ) , args )
155152
0 commit comments