@@ -20,7 +20,7 @@ import { timeoutUtils } from 'aws-core-vscode/shared'
20
20
import assert from 'assert'
21
21
import sinon from 'sinon'
22
22
import * as vscode from 'vscode'
23
- import fs from 'fs' // eslint-disable-line no-restricted-imports
23
+ import path from 'path'
24
24
25
25
const buildRawCodeScanIssue = ( params ?: Partial < RawCodeScanIssue > ) : RawCodeScanIssue => ( {
26
26
filePath : 'workspaceFolder/python3.7-plain-sam-app/hello_world/app.py' ,
@@ -65,17 +65,18 @@ const buildMockListCodeScanFindingsResponse = (
65
65
nextToken : nextToken ? 'nextToken' : undefined ,
66
66
} )
67
67
68
+ function getWorkspaceFolder ( ) : string {
69
+ return (
70
+ vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri . fsPath ??
71
+ path . join ( __dirname , '../../../../../../core/src/testFixtures/workspaceFolder' )
72
+ )
73
+ }
74
+
68
75
describe ( 'securityScanHandler' , function ( ) {
69
76
describe ( 'listScanResults' , function ( ) {
70
77
let mockClient : Stub < DefaultCodeWhispererClient >
71
78
beforeEach ( function ( ) {
72
79
mockClient = stub ( DefaultCodeWhispererClient )
73
- sinon . stub ( fs , 'existsSync' ) . returns ( true )
74
- sinon . stub ( fs , 'statSync' ) . returns ( { isFile : ( ) => true } as fs . Stats )
75
- } )
76
-
77
- afterEach ( function ( ) {
78
- sinon . restore ( )
79
80
} )
80
81
81
82
it ( 'should make ListCodeScanFindings request and aggregate findings by file path' , async function ( ) {
@@ -85,14 +86,13 @@ describe('securityScanHandler', function () {
85
86
mockClient ,
86
87
'jobId' ,
87
88
'codeScanFindingsSchema' ,
88
- [ 'projectPath' ] ,
89
+ [ getWorkspaceFolder ( ) ] ,
89
90
CodeAnalysisScope . PROJECT ,
90
91
undefined
91
92
)
92
93
93
- assert . equal ( aggregatedCodeScanIssueList . length , 2 )
94
+ assert . equal ( aggregatedCodeScanIssueList . length , 1 )
94
95
assert . equal ( aggregatedCodeScanIssueList [ 0 ] . issues . length , 1 )
95
- assert . equal ( aggregatedCodeScanIssueList [ 1 ] . issues . length , 1 )
96
96
} )
97
97
98
98
it ( 'should handle ListCodeScanFindings request with paginated response' , async function ( ) {
@@ -123,12 +123,12 @@ describe('securityScanHandler', function () {
123
123
mockClient ,
124
124
'jobId' ,
125
125
'codeScanFindingsSchema' ,
126
- [ 'projectPath' ] ,
126
+ [ getWorkspaceFolder ( ) ] ,
127
127
CodeAnalysisScope . PROJECT ,
128
128
undefined
129
129
)
130
130
131
- assert . equal ( aggregatedCodeScanIssueList . length , 2 )
131
+ assert . equal ( aggregatedCodeScanIssueList . length , 1 )
132
132
assert . equal ( aggregatedCodeScanIssueList [ 0 ] . issues . length , 3 )
133
133
} )
134
134
@@ -145,7 +145,7 @@ describe('securityScanHandler', function () {
145
145
mockClient ,
146
146
'jobId' ,
147
147
'codeScanFindingsSchema' ,
148
- [ 'projectPath' ] ,
148
+ [ getWorkspaceFolder ( ) ] ,
149
149
scope ,
150
150
undefined
151
151
)
0 commit comments