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

Commit

Permalink
fix: Respond to PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarlow12 committed Jun 21, 2019
1 parent 5b99544 commit 518144c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/plugins/deploy/azureDeployPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("Deploy plugin", () => {

it("lists deployments", async () => {
const deployments = MockFactory.createTestDeployments();
ResourceService.prototype.listDeployments = jest.fn(() => Promise.resolve(deployments));
ResourceService.prototype.getDeployments = jest.fn(() => Promise.resolve(deployments));
const sls = MockFactory.createTestServerless();
const options = MockFactory.createTestServerlessOptions();
const plugin = new AzureDeployPlugin(sls, options);
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/deploy/azureDeployPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ export class AzureDeployPlugin {
private async list() {
this.serverless.cli.log("Listing deployments");
const resourceService = new ResourceService(this.serverless, this.options);
const deployments = await resourceService.listDeployments();
const deployments = await resourceService.getDeployments();
if (!deployments || deployments.length === 0) {
this.serverless.cli.log(`No deployments found for resource group '${resourceService.getResourceGroup()}'`);
return;
}
let stringDeployments = "\n\nDeployments";

for (const dep of deployments) {
stringDeployments += "\n-----------\n"
stringDeployments += `Name: ${dep.name}\n`
Expand Down
4 changes: 4 additions & 0 deletions src/services/baseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export abstract class BaseService {
throw new Error(`Azure Credentials has not been set in ${this.constructor.name}`);
}
}

public getResourceGroup(): string {
return this.resourceGroup;
}

/**
* Sends an API request using axios HTTP library
Expand Down
2 changes: 1 addition & 1 deletion src/services/resourceService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe("Resource Service", () => {
sls.variables["azureCredentials"] = "fake credentials"
const options = MockFactory.createTestServerlessOptions();
const service = new ResourceService(sls, options);
const deps = await service.listDeployments();
const deps = await service.getDeployments();
expect(deps).toEqual(deployments);
});
});
2 changes: 1 addition & 1 deletion src/services/resourceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ResourceService extends BaseService {
this.resourceClient = new ResourceManagementClient(this.credentials, this.subscriptionId);
}

public async listDeployments() {
public async getDeployments() {
this.log(`Listing deployments for resource group '${this.resourceGroup}':`);
return await this.resourceClient.deployments.listByResourceGroup(this.resourceGroup);
}
Expand Down

0 comments on commit 518144c

Please sign in to comment.