Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/plugins/login/azureLoginPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,17 @@ describe("Login Plugin", () => {
expect(sls.variables["subscriptionId"]).toEqual("azureSubId");
});

it("logs an error from authentication and exits process", async () => {
it("logs an error from authentication and crashes with it", async () => {
unsetServicePrincipalEnvVariables();
process.exit = jest.fn() as any;
const errorMessage = "This is my error message";
const error = new Error("This is my error message")
AzureLoginService.interactiveLogin = jest.fn(() => {
throw new Error(errorMessage);
throw error;
});
const sls = MockFactory.createTestServerless();
await invokeLoginHook(false, sls);
await expect(invokeLoginHook(false, sls)).rejects.toThrow(error);
expect(AzureLoginService.interactiveLogin).toBeCalled()
expect(AzureLoginService.servicePrincipalLogin).not.toBeCalled();
expect(sls.cli.log).lastCalledWith(`Error: ${errorMessage}`);
expect(process.exit).toBeCalledWith(0);
expect(sls.cli.log).lastCalledWith("Error logging into azure");
});

it("Uses the user specified subscription ID", async () => {
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/login/azureLoginPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export class AzureLoginPlugin extends AzureBasePlugin<AzureLoginOptions> {
}
catch (e) {
this.log("Error logging into azure");
this.log(`${e}`);
process.exit(0);
throw e; // Let Serverless Framework communicate the error
}
}
}