CB-12546: based on android command exit code and stdout, conditionally try to invoke avdmanager to list out AVD images. tweak relevant test to match behaviour. small tweak to use exposed methods for checking platform (for easier future stubbing).

This commit is contained in:
filmaj
2017-03-14 15:15:49 -07:00
parent d40c22441f
commit 4a354bba86
3 changed files with 36 additions and 16 deletions
+12 -1
View File
@@ -84,13 +84,24 @@ describe("emulator", function () {
});
it("should catch if `android` exits with non-zero code and specific stdout, and delegate to `avdmanager` if it can find it", function() {
spyOn(shelljs, "which").and.callFake(function(cmd) {
if (cmd == "avdmanager") {
if (cmd == "android") {
return true;
} else {
return false;
}
});
var avdmanager_spy = spyOn(emu, "list_images_using_avdmanager");
// Fake out the old promise to feign a failed `android` command
spyOn(emu, "list_images_using_android").and.returnValue({
catch:function(cb) {
cb({
code: 1,
stdout: ["The android command is no longer available.",
"For manual SDK and AVD management, please use Android Studio.",
"For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager"].join("\n")
});
}
});
emu.list_images();
expect(avdmanager_spy).toHaveBeenCalled();
});