Skip to content

Commit 7c32eb1

Browse files
committed
migrate amazonq off of aws-sdk v2
1 parent 185406d commit 7c32eb1

File tree

2 files changed

+19
-33
lines changed

2 files changed

+19
-33
lines changed

packages/amazonq/test/unit/codewhisperer/service/codewhisperer.test.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
codeWhispererClient,
1313
} from 'aws-core-vscode/codewhisperer'
1414
import { globals, getClientId, getOperatingSystem } from 'aws-core-vscode/shared'
15-
import { AWSError, Request } from 'aws-sdk'
1615
import { createSpyClient } from 'aws-core-vscode/test'
1716

1817
describe('codewhisperer', async function () {
@@ -102,14 +101,11 @@ describe('codewhisperer', async function () {
102101
})
103102

104103
it('sendTelemetryEvent should be called with UserContext payload', async function () {
105-
const clientSpyStub = sinon.stub(clientSpy, 'sendTelemetryEvent').returns({
106-
promise: () =>
107-
Promise.resolve({
108-
$response: {
109-
requestId: '',
110-
},
111-
}),
112-
} as Request<SendTelemetryEventResponse, AWSError>)
104+
const clientSpyStub = sinon.stub(clientSpy, 'sendTelemetryEvent').resolves({
105+
$metadata: {
106+
requestId: '',
107+
},
108+
} as SendTelemetryEventResponse)
113109

114110
const expectedUserContext = {
115111
ideCategory: 'VSCODE',
@@ -127,14 +123,11 @@ describe('codewhisperer', async function () {
127123
isSso: boolean,
128124
isTelemetryEnabled: boolean
129125
) {
130-
const clientSpyStub = sinon.stub(clientSpy, 'sendTelemetryEvent').returns({
131-
promise: () =>
132-
Promise.resolve({
133-
$response: {
134-
requestId: '',
135-
},
136-
}),
137-
} as Request<SendTelemetryEventResponse, AWSError>)
126+
const clientSpyStub = sinon.stub(clientSpy, 'sendTelemetryEvent').resolves({
127+
$metadata: {
128+
requestId: '',
129+
},
130+
} as SendTelemetryEventResponse)
138131

139132
const authUtilStub = sinon.stub(AuthUtil.instance, 'isValidEnterpriseSsoInUse').returns(isSso)
140133
await globals.telemetry.setTelemetryEnabled(isTelemetryEnabled)

packages/amazonq/test/unit/codewhisperer/service/securityScanHandler.test.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { PromiseResult } from 'aws-sdk/lib/request'
76
import { Stub, stub } from 'aws-core-vscode/test'
8-
import { AWSError, HttpResponse } from 'aws-sdk'
97
import {
108
CodeAnalysisScope,
119
RawCodeScanIssue,
@@ -52,20 +50,15 @@ const buildRawCodeScanIssue = (params?: Partial<RawCodeScanIssue>): RawCodeScanI
5250
const buildMockListCodeScanFindingsResponse = (
5351
codeScanFindings: string = JSON.stringify([buildRawCodeScanIssue()]),
5452
nextToken?: boolean
55-
): Awaited<Promise<PromiseResult<ListCodeScanFindingsResponse, AWSError>>> => ({
56-
$response: {
57-
hasNextPage: () => false,
58-
nextPage: () => null, // eslint-disable-line unicorn/no-null
59-
data: undefined,
60-
error: undefined,
61-
requestId: '',
62-
redirectCount: 0,
63-
retryCount: 0,
64-
httpResponse: new HttpResponse(),
65-
},
66-
codeScanFindings,
67-
nextToken: nextToken ? 'nextToken' : undefined,
68-
})
53+
): Promise<ListCodeScanFindingsResponse> =>
54+
Promise.resolve({
55+
$metadata: {
56+
httpStatusCode: 200,
57+
requestId: '',
58+
},
59+
codeScanFindings,
60+
nextToken: nextToken ? 'nextToken' : undefined,
61+
})
6962

7063
function getWorkspaceFolder(): string {
7164
return (

0 commit comments

Comments
 (0)