@@ -176,14 +176,13 @@ describe("androidVirtualDeviceService", () => {
176
176
assert . deepEqual ( result . devices , [ ] ) ;
177
177
assert . deepEqual ( result . errors , [ ] ) ;
178
178
} ) ;
179
- it ( "should return an empty array when `avdmanager list avds` command fails" , async ( ) => {
179
+ it ( "should return an empty array and no errors when `avdmanager list avds` command fails" , async ( ) => {
180
180
const avdManagerError = "some error while executing avdmanager list avds" ;
181
181
const avdService = mockAvdService ( { avdManagerError } ) ;
182
182
const result = await avdService . getEmulatorImages ( [ ] ) ;
183
183
assert . lengthOf ( result . devices , 0 ) ;
184
184
assert . deepEqual ( result . devices , [ ] ) ;
185
- assert . lengthOf ( result . errors , 1 ) ;
186
- assert . deepEqual ( result . errors , [ avdManagerError ] ) ;
185
+ assert . lengthOf ( result . errors , 0 ) ;
187
186
} ) ;
188
187
it ( "should return all emulators when there are available emulators and no running emulators" , async ( ) => {
189
188
const avdService = mockAvdService ( {
@@ -214,6 +213,24 @@ describe("androidVirtualDeviceService", () => {
214
213
assert . deepEqual ( result [ 1 ] , getAvailableEmulatorData ( { displayName : "Nexus_5X_API_28" , imageIdentifier : "Nexus_5X_API_28" , version : "9.0.0" , model : "Nexus 5X" } ) ) ;
215
214
assert . deepEqual ( result [ 2 ] , getAvailableEmulatorData ( { displayName : "Nexus_6P_API_28" , imageIdentifier : "Nexus_6P_API_28" , version : "9.0.0" , model : "Nexus 6P" } ) ) ;
216
215
} ) ;
216
+ // In this case we should fallback to list avd directory and should't report errors from avdmanager
217
+ it ( "should return devices and no errors when there is an error on avdmanager's stderr" , async ( ) => {
218
+ const iniFilesData = getIniFilesData ( ) ;
219
+ const testInjector = createTestInjector ( {
220
+ avdManagerOutput : "" ,
221
+ avdManagerError : "my test error" ,
222
+ iniFilesData
223
+ } ) ;
224
+
225
+ const fs = testInjector . resolve ( "fs" ) ;
226
+ fs . readDirectory = ( ) => _ . keys ( iniFilesData ) ;
227
+
228
+ const avdService = testInjector . resolve ( "androidVirtualDeviceService" ) ;
229
+ const result = await avdService . getEmulatorImages ( [ "emulator-5554 device" ] ) ;
230
+
231
+ assert . deepEqual ( result . devices . length , 3 ) ;
232
+ assert . deepEqual ( result . errors . length , 0 ) ;
233
+ } ) ;
217
234
} ) ;
218
235
219
236
describe ( "when avdmanager is not found" , ( ) => {
0 commit comments