Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions packages/core/src/test/codewhisperer/startSecurityScan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
scansLimitReachedErrorMessage,
} from '../../codewhisperer/models/constants'
import * as model from '../../codewhisperer/models/model'
import { CodewhispererSecurityScan } from '../../shared/telemetry/telemetry.gen'
import * as errors from '../../shared/errors'
import * as timeoutUtils from '../../shared/utilities/timeoutUtils'
import { SecurityIssuesTree } from '../../codewhisperer'
Expand Down Expand Up @@ -232,7 +231,7 @@ describe('startSecurityScan', function () {
codewhispererCodeScanIssuesWithFixes: 0,
codewhispererCodeScanScope: 'PROJECT',
passive: false,
} as CodewhispererSecurityScan)
})
})

it('Should cancel a scan if a newer one has started', async function () {
Expand Down Expand Up @@ -261,7 +260,7 @@ describe('startSecurityScan', function () {
result: 'Cancelled',
reasonDesc: 'Security scan stopped by user.',
reason: 'DefaultError',
} as unknown as CodewhispererSecurityScan,
},
{
result: 'Succeeded',
},
Expand Down Expand Up @@ -323,7 +322,7 @@ describe('startSecurityScan', function () {
reason: 'CodeScanJobFailedError',
reasonDesc: 'CodeScanJobFailedError: Security scan failed.',
passive: false,
} as unknown as CodewhispererSecurityScan)
})
})

it('Should show notification when throttled for project scans', async function () {
Expand Down Expand Up @@ -353,7 +352,7 @@ describe('startSecurityScan', function () {
reason: 'ThrottlingException',
reasonDesc: `ThrottlingException: Maximum com.amazon.aws.codewhisperer.StartCodeAnalysis reached for this month.`,
passive: false,
} as unknown as CodewhispererSecurityScan)
})
})

it('Should set monthly quota exceeded when throttled for auto file scans', async function () {
Expand Down Expand Up @@ -385,6 +384,6 @@ describe('startSecurityScan', function () {
reason: 'ThrottlingException',
reasonDesc: 'ThrottlingException: Maximum file scans count reached for this month',
passive: true,
} as unknown as CodewhispererSecurityScan)
})
})
})
6 changes: 3 additions & 3 deletions packages/core/src/test/shared/telemetry/spans.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('TelemetryTracer', function () {
})

assertTelemetry(metricName, { result: 'Succeeded', source: 'bar' })
assertTelemetry('apigateway_copyUrl', {} as MetricShapes['apigateway_copyUrl'])
assertTelemetry('apigateway_copyUrl', {})
})

it('writes to all new spans in the current context', function () {
Expand All @@ -112,7 +112,7 @@ describe('TelemetryTracer', function () {
})

assertTelemetry(metricName, { result: 'Succeeded', source: 'bar' })
assertTelemetry('apigateway_copyUrl', { result: 'Succeeded', source: 'bar' } as any)
assertTelemetry('apigateway_copyUrl', { result: 'Succeeded', source: 'bar' })
})

it('does not propagate state outside of the execution', function () {
Expand Down Expand Up @@ -310,7 +310,7 @@ describe('TelemetryTracer', function () {
it('attaches the parent id to the child span', function () {
tracer.run(metricName, () => tracer.run(nestedName, () => {}))
assertTelemetry(metricName, { result: 'Succeeded' })
assertTelemetry(nestedName, { result: 'Succeeded', parentId: testId } as any)
assertTelemetry(nestedName, { result: 'Succeeded', parentId: testId })
})

it('should set trace id', function () {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/test/testUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,15 @@ export function assertNoTelemetryMatch(re: RegExp | string): void | never {
*/
export function assertTelemetry<K extends MetricName>(
name: K,
expected: MetricShapes[K] | MetricShapes[K][]
expected: Partial<MetricShapes[K]> | Partial<MetricShapes[K]>[]
): void | never
export function assertTelemetry<K extends MetricName>(
name: K,
expected: MetricShapes[MetricName] | MetricShapes[MetricName][]
expected: Partial<MetricShapes[MetricName]> | Partial<MetricShapes[MetricName]>[]
): void | never
export function assertTelemetry<K extends MetricName>(
name: K,
expected: MetricShapes[K] | MetricShapes[K][]
expected: Partial<MetricShapes[K]> | Partial<MetricShapes[K]>[]
): void | never {
const expectedList = Array.isArray(expected) ? expected : [expected]
const query = { metricName: name }
Expand Down
Loading