Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
fix: Exit process when error logging into Azure (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarlow12 authored Jul 9, 2019
1 parent c51a865 commit 11c80b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/plugins/login/loginPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,18 @@ describe("Login Plugin", () => {
expect(sls.variables["subscriptionId"]).toEqual("azureSubId");
});

it("logs an error from authentication", async () => {
it("logs an error from authentication and exits process", async () => {
unsetServicePrincipalEnvVariables();
process.exit = jest.fn() as any;
const errorMessage = "This is my error message";
AzureLoginService.interactiveLogin = jest.fn(() => {
throw new Error(errorMessage);
});
});
const sls = MockFactory.createTestServerless();
await invokeLoginHook(false, sls);
expect(AzureLoginService.interactiveLogin).toBeCalled()
expect(AzureLoginService.servicePrincipalLogin).not.toBeCalled();
expect(sls.cli.log).lastCalledWith(`Error: ${errorMessage}`)
expect(sls.cli.log).lastCalledWith(`Error: ${errorMessage}`);
expect(process.exit).toBeCalledWith(0);
});
})
});
1 change: 1 addition & 0 deletions src/plugins/login/loginPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class AzureLoginPlugin {
catch (e) {
this.serverless.cli.log("Error logging into azure");
this.serverless.cli.log(`${e}`);
process.exit(0);
}
}
}

0 comments on commit 11c80b3

Please sign in to comment.