Skip to content

Commit

Permalink
test: added hosting with launch test case for deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithad0703 committed Jun 26, 2024
1 parent 57af772 commit 6f7b5f5
Showing 1 changed file with 42 additions and 21 deletions.
63 changes: 42 additions & 21 deletions test/unit/commands/app/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const region: { cma: string; cda: string; name: string } =
const developerHubBaseUrl = getDeveloperHubUrl();

describe("app:deploy", () => {
describe("Deploy an with custom hosting", () => {
describe("Deploy an app with custom hosting", () => {
test
.stdout({ print: process.env.PRINT === "true" || false })
.stub(ux.action, "stop", () => {})
Expand All @@ -22,7 +22,7 @@ describe("app:deploy", () => {
App: mock.apps[1].name,
Organization: mock.organizations[0].name,
"hosting types": "Custom Hosting",
"app-url": "https://example.com",
appUrl: "https://example.com",
};
return (cases as Record<string, any>)[prompt.name];
})
Expand All @@ -35,40 +35,61 @@ describe("app:deploy", () => {
api
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
.reply(200, {
data: mock.apps,
data: mock.apps2,
})
)
.nock(`https://${developerHubBaseUrl}`, (api) =>
api.put(`/manifests/${mock.apps[1].uid}`).reply(200, {
data: mock.apps,
})
api.put(`/manifests/${mock.apps2[1].uid}`).reply(200, mock.deploy_custom_host)
)
.nock(`https://${developerHubBaseUrl}`, (api) =>
.command(["app:deploy"])
.do(({ stdout }) => {
expect(stdout).to.contain(
$t(messages.APP_DEPLOYED, { app: mock.apps[1].name })
);
})
.it("should deploy the app with custom hosting");
});

describe("Deploy an app with Hosting with Launch with existing project", () => {
test
.stdout({ print: process.env.PRINT === "true" || false })
.stub(ux.action, "stop", () => {})
.stub(ux.action, "start", () => {})
.stub(cliux, "inquire", async (...args: any) => {
const [prompt]: any = args;
const cases = {
App: mock.apps2[1].name,
Organization: mock.organizations[0].name,
"hosting types": "Hosting with Launch",
"provider": "launch",
"selected_launch_project":"existing",
"deployment_url": "https://example.com",
"environment_uid": "environment_uid",
"project_uid": "project_uid",
};
return (cases as Record<string, any>)[prompt.name];
})
.nock(region.cma, (api) =>
api
.patch(`/manifests/${mock.apps[1].uid}/hosting/disconnect`)
.reply(200, {
data: mock.apps,
})
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
.reply(200, { organizations: mock.organizations })
)
.nock(`https://${developerHubBaseUrl}`, (api) =>
api
.put(`/manifests/${mock.apps[1].uid}/hosting`, {
hosting: {
provider: "external",
deployment_url: "https://example.com",
},
uid: mock.apps[1].uid,
})
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
.reply(200, {
data: mock.apps,
data: mock.apps2,
})
)
.nock(`https://${developerHubBaseUrl}`, (api) =>
api.put(`/manifests/${mock.apps2[1].uid}`).reply(200, mock.deploy_launch_host)
)
.command(["app:deploy"])
.do(({ stdout }) => {
expect(stdout).to.contain(
$t(messages.APP_DEPLOYED, { app: mock.apps[1].name })
$t(messages.APP_DEPLOYED, { app: mock.apps2[1].name })
);
})
.it("should deploy the app with custom hosting");
.it("should deploy the app with Hosting with Launch with existing project");
});
});

0 comments on commit 6f7b5f5

Please sign in to comment.