Skip to content

Commit 0575e2a

Browse files
committed
test: use different sandbox for user agent tests
1 parent 3581e29 commit 0575e2a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

packages/core/src/test/lambda/remoteDebugging/ldkClient.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,13 @@ describe('LdkClient', () => {
526526

527527
describe('Client User-Agent', () => {
528528
let expectedUserAgentPairs: UserAgent
529-
before(() => {
529+
let userAgentSandbox: sinon.SinonSandbox
530+
beforeEach(() => {
531+
userAgentSandbox = sinon.createSandbox()
530532
// Stub getUserAgentPairs at the telemetryUtil level to return known pairs
531-
const getUserAgentPairsStub = sandbox.stub(telemetryUtil, 'getUserAgentPairs')
533+
const getUserAgentPairsStub = userAgentSandbox.stub(telemetryUtil, 'getUserAgentPairs')
532534
const generalUserAgents: UserAgent = [
533-
['AWS-Toolkit-For-VSCode', 'testVersion'],
535+
['AWS-Toolkit-For-VSCode', 'testVersionForUA'],
534536
['Visual-Studio-Code', '1.0.0'],
535537
['ClientId', 'test-client-id'],
536538
]
@@ -539,6 +541,10 @@ describe('LdkClient', () => {
539541
expectedUserAgentPairs = lambdaDebugUserAgent.concat(generalUserAgents)
540542
})
541543

544+
afterEach(() => {
545+
userAgentSandbox.restore()
546+
})
547+
542548
it('should create Lambda client with correct user-agent', async () => {
543549
// Restore the existing stub and create a new one to track calls
544550
const existingStub = (utils.getLambdaClientWithAgent as any).restore
@@ -550,7 +556,7 @@ describe('LdkClient', () => {
550556

551557
// Stub the Lambda sdkClientBuilderV3 to capture the client options
552558
let capturedClientOptions: any
553-
const createAwsServiceStubLambda = sandbox.stub(globals.sdkClientBuilderV3, 'createAwsService')
559+
const createAwsServiceStubLambda = userAgentSandbox.stub(globals.sdkClientBuilderV3, 'createAwsService')
554560
createAwsServiceStubLambda.callsFake((options: any) => {
555561
capturedClientOptions = options
556562
// Return a mock Lambda client that has the required methods
@@ -590,7 +596,7 @@ describe('LdkClient', () => {
590596
}
591597
// Stub the sdkClientBuilderV3 to capture the client options
592598
let capturedClientOptions: any
593-
const createAwsServiceStubIoT = sandbox.stub(globals.sdkClientBuilderV3, 'createAwsService')
599+
const createAwsServiceStubIoT = userAgentSandbox.stub(globals.sdkClientBuilderV3, 'createAwsService')
594600
createAwsServiceStubIoT.callsFake((options: any) => {
595601
capturedClientOptions = options
596602
return mockIoTSTClient as any

0 commit comments

Comments
 (0)