Skip to content

Commit 96b9fb9

Browse files
feat: added a test to check error condition
1 parent 8c72e9b commit 96b9fb9

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

test/unit/commands/app/delete.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,49 @@ describe("app:delete", () => {
8484
})
8585
.it("should delete the app")
8686
});
87+
describe("app:delete error handling", () => {
88+
test
89+
.stdout({ print: process.env.PRINT === "true" || false })
90+
.stub(ux.action, "stop", () => {})
91+
.stub(ux.action, "start", () => {})
92+
.stub(cliux, "inquire", async (...args: any) => {
93+
const [prompt]: any = args;
94+
const cases = {
95+
Organization: 'test org 1',
96+
App: 'App 1'
97+
}
98+
return (cases as Record<string, any>)[prompt.name];
99+
})
100+
.nock(region.cma, (api) =>
101+
api
102+
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
103+
.reply(200, { organizations: mock.organizations })
104+
)
105+
.nock(`https://${developerHubBaseUrl}`, (api) =>
106+
api
107+
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
108+
.reply(200, {
109+
data: mock.apps,
110+
})
111+
)
112+
.nock(`https://${developerHubBaseUrl}`, (api) =>
113+
api
114+
.get("/manifests/app-uid-1/installations")
115+
.replyWithError({
116+
"status": 409,
117+
"message": [
118+
"(1) installations found for this app"
119+
],
120+
"error": "Bad Request",
121+
"statusText": "Conflict"
122+
})
123+
)
124+
.command([
125+
"app:delete"
126+
])
127+
.do(({ stdout }) => {
128+
expect(stdout).to.contain(messages.CONTACT_SUPPORT)
129+
})
130+
.it("should throw an error while deleting the app")
131+
});
87132
})

0 commit comments

Comments
 (0)