Skip to content

Commit

Permalink
improvement: add protection to more commands
Browse files Browse the repository at this point in the history
  • Loading branch information
eysi09 committed Dec 5, 2019
1 parent e3bf48f commit df76dc3
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions garden-service/src/commands/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type DeleteSecretArgs = typeof deleteSecretArgs
export class DeleteSecretCommand extends Command<typeof deleteSecretArgs> {
name = "secret"
help = "Delete a secret from the environment."
protected = true

description = dedent`
Returns with an error if the provided key could not be found by the provider.
Expand Down Expand Up @@ -79,6 +80,7 @@ export class DeleteEnvironmentCommand extends Command {
name = "environment"
alias = "env"
help = "Deletes a running environment."
protected = true

description = dedent`
This will delete all services in the specified environment, and trigger providers to clear up any other resources
Expand Down Expand Up @@ -111,6 +113,7 @@ export class DeleteServiceCommand extends Command {
alias = "services"
help = "Deletes running services."
arguments = deleteServiceArgs
protected = true

description = dedent`
Deletes (i.e. un-deploys) the specified services. Note that this command does not take into account any
Expand Down
5 changes: 5 additions & 0 deletions garden-service/test/unit/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ describe("commands.build", () => {
"stage-build.module-b": {},
})
})

it("should be protected", async () => {
const command = new BuildCommand()
expect(command.protected).to.be.true
})
})
13 changes: 13 additions & 0 deletions garden-service/test/unit/src/commands/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ describe("DeleteSecretCommand", () => {
"not-found"
)
})

it("should be protected", async () => {
const command = new DeleteSecretCommand()
expect(command.protected).to.be.true
})
})

const getServiceStatus = async (): Promise<ServiceStatus> => {
Expand Down Expand Up @@ -134,6 +139,10 @@ describe("DeleteEnvironmentCommand", () => {
})
expect(deletedServices.sort()).to.eql(["service-a", "service-b", "service-c", "service-d"])
})

it("should be protected", async () => {
expect(command.protected).to.be.true
})
})

describe("DeleteServiceCommand", () => {
Expand Down Expand Up @@ -211,4 +220,8 @@ describe("DeleteServiceCommand", () => {
"service-b": { forwardablePorts: [], state: "unknown", ingresses: [], detail: {} },
})
})

it("should be protected", async () => {
expect(command.protected).to.be.true
})
})
5 changes: 5 additions & 0 deletions garden-service/test/unit/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,9 @@ describe("DeployCommand", () => {
"deploy.service-b": { forwardablePorts: [], version: "1", state: "ready", detail: {} },
})
})

it("should be protected", async () => {
const command = new DeployCommand()
expect(command.protected).to.be.true
})
})
9 changes: 9 additions & 0 deletions garden-service/test/unit/src/commands/dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { expect } from "chai"
import { DevCommand } from "../../../../src/commands/dev"

describe("DevCommand", () => {
it("should be protected", async () => {
const command = new DevCommand()
expect(command.protected).to.be.true
})
})
9 changes: 9 additions & 0 deletions garden-service/test/unit/src/commands/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { expect } from "chai"
import { InitCommand } from "../../../../src/commands/init"

describe("DevCommand", () => {
it("should be protected", async () => {
const command = new InitCommand()
expect(command.protected).to.be.true
})
})
5 changes: 5 additions & 0 deletions garden-service/test/unit/src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,9 @@ describe("commands.test", () => {
})
).to.be.false
})

it("should be protected", async () => {
const command = new TestCommand()
expect(command.protected).to.be.true
})
})

0 comments on commit df76dc3

Please sign in to comment.