@@ -101,8 +101,7 @@ suite('Result Resolver tests', () => {
101
101
cancelationToken , // token
102
102
) ;
103
103
} ) ;
104
- // what about if the error node already exists: this.testController.items.get(`DiscoveryError:${workspacePath}`);
105
- test ( 'resolveDiscovery should create error node on error with correct params' , async ( ) => {
104
+ test ( 'resolveDiscovery should create error node on error with correct params and no root node with tests in payload' , async ( ) => {
106
105
// test specific constants used expected values
107
106
testProvider = 'pytest' ;
108
107
workspaceUri = Uri . file ( '/foo/bar' ) ;
@@ -136,6 +135,61 @@ suite('Result Resolver tests', () => {
136
135
// header of createErrorTestItem is (options: ErrorTestItemOptions, testController: TestController, uri: Uri)
137
136
sinon . assert . calledWithMatch ( createErrorTestItemStub , sinon . match . any , sinon . match . any ) ;
138
137
} ) ;
138
+ test ( 'resolveDiscovery should create error and root node when error and tests exist on payload' , async ( ) => {
139
+ // test specific constants used expected values
140
+ testProvider = 'pytest' ;
141
+ workspaceUri = Uri . file ( '/foo/bar' ) ;
142
+ resultResolver = new ResultResolver . PythonResultResolver ( testController , testProvider , workspaceUri ) ;
143
+ const errorMessage = 'error msg A' ;
144
+ const expectedErrorMessage = `${ defaultErrorMessage } \r\n ${ errorMessage } ` ;
145
+
146
+ // create test result node
147
+ const tests : DiscoveredTestNode = {
148
+ path : 'path' ,
149
+ name : 'name' ,
150
+ type_ : 'folder' ,
151
+ id_ : 'id' ,
152
+ children : [ ] ,
153
+ } ;
154
+ // stub out return values of functions called in resolveDiscovery
155
+ const payload : DiscoveredTestPayload = {
156
+ cwd : workspaceUri . fsPath ,
157
+ status : 'error' ,
158
+ error : [ errorMessage ] ,
159
+ tests,
160
+ } ;
161
+ const errorTestItemOptions : testItemUtilities . ErrorTestItemOptions = {
162
+ id : 'id' ,
163
+ label : 'label' ,
164
+ error : 'error' ,
165
+ } ;
166
+
167
+ // stub out functionality of buildErrorNodeOptions and createErrorTestItem which are called in resolveDiscovery
168
+ const buildErrorNodeOptionsStub = sinon . stub ( util , 'buildErrorNodeOptions' ) . returns ( errorTestItemOptions ) ;
169
+ const createErrorTestItemStub = sinon . stub ( testItemUtilities , 'createErrorTestItem' ) . returns ( blankTestItem ) ;
170
+
171
+ // stub out functionality of populateTestTreeStub which is called in resolveDiscovery
172
+ const populateTestTreeStub = sinon . stub ( util , 'populateTestTree' ) . returns ( ) ;
173
+ // call resolve discovery
174
+ resultResolver . resolveDiscovery ( payload , cancelationToken ) ;
175
+
176
+ // assert the stub functions were called with the correct parameters
177
+
178
+ // builds an error node root
179
+ sinon . assert . calledWithMatch ( buildErrorNodeOptionsStub , workspaceUri , expectedErrorMessage , testProvider ) ;
180
+ // builds an error item
181
+ sinon . assert . calledWithMatch ( createErrorTestItemStub , sinon . match . any , sinon . match . any ) ;
182
+
183
+ // also calls populateTestTree with the discovery test results
184
+ sinon . assert . calledWithMatch (
185
+ populateTestTreeStub ,
186
+ testController , // testController
187
+ tests , // testTreeData
188
+ undefined , // testRoot
189
+ resultResolver , // resultResolver
190
+ cancelationToken , // token
191
+ ) ;
192
+ } ) ;
139
193
} ) ;
140
194
suite ( 'Test execution result resolver' , ( ) => {
141
195
let resultResolver : ResultResolver . PythonResultResolver ;
0 commit comments