Skip to content

Commit 82640ff

Browse files
Test cases updated based on config and update command flow changes
1 parent 0409525 commit 82640ff

2 files changed

Lines changed: 78 additions & 6 deletions

File tree

test/unit/commands/app/update.test.ts

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("app:update", () => {
2626
.stub(cliux, "inquire", async (...args: any) => {
2727
const [prompt]: any = args;
2828
const cases = {
29-
appUid: "app-uid-1",
29+
App: "App 1",
3030
Organization: "test org 1",
3131
appManifest: "test-manifest",
3232
};
@@ -38,6 +38,13 @@ describe("app:update", () => {
3838
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
3939
.reply(200, { organizations: mock.organizations })
4040
)
41+
.nock(`https://${developerHubBaseUrl}`, (api) =>
42+
api
43+
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
44+
.reply(200, {
45+
data: mock.apps,
46+
})
47+
)
4148
.nock(`https://${developerHubBaseUrl}`, (api) =>
4249
api.get("/manifests/app-uid-1").reply(200, {
4350
data: { ...manifestData, name: "test-app", version: 1 },
@@ -58,6 +65,7 @@ describe("app:update", () => {
5865
)
5966
.it("should update a app");
6067
});
68+
6169
describe("Update app with `--data-dir` flag", () => {
6270
test
6371
.stdout({ print: process.env.PRINT === "true" || false })
@@ -67,7 +75,7 @@ describe("app:update", () => {
6775
.stub(cliux, "inquire", async (...args: any) => {
6876
const [prompt]: any = args;
6977
const cases = {
70-
appUid: "app-uid-1",
78+
App: "App 1",
7179
Organization: "test org 1",
7280
appManifest: "test-manifest",
7381
};
@@ -79,6 +87,13 @@ describe("app:update", () => {
7987
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
8088
.reply(200, { organizations: mock.organizations })
8189
)
90+
.nock(`https://${developerHubBaseUrl}`, (api) =>
91+
api
92+
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
93+
.reply(200, {
94+
data: mock.apps,
95+
})
96+
)
8297
.nock(`https://${developerHubBaseUrl}`, (api) =>
8398
api.get("/manifests/app-uid-1").reply(200, {
8499
data: { ...manifestData, name: "test-app", version: 1 },
@@ -99,6 +114,7 @@ describe("app:update", () => {
99114
)
100115
.it("should update a app");
101116
});
117+
102118
describe("Update app with wrong `manifest.json` path", () => {
103119
test
104120
.stdout({ print: process.env.PRINT === "true" || false })
@@ -125,6 +141,7 @@ describe("app:update", () => {
125141
.do(({ stdout }) => expect(stdout).to.contain(messages.MAX_RETRY_LIMIT))
126142
.it("should fail with manifest max retry message");
127143
});
144+
128145
describe("Update app with wrong `app-uid`", () => {
129146
test
130147
.stdout({ print: process.env.PRINT === "true" || false })
@@ -134,7 +151,7 @@ describe("app:update", () => {
134151
.stub(cliux, "inquire", async (...args: any) => {
135152
const [prompt]: any = args;
136153
const cases = {
137-
appUid: "app-uid-2",
154+
App: "App 2",
138155
Organization: "test org 1",
139156
appManifest: "test-manifest",
140157
};
@@ -146,6 +163,27 @@ describe("app:update", () => {
146163
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
147164
.reply(200, { organizations: mock.organizations })
148165
)
166+
.nock(`https://${developerHubBaseUrl}`, (api) =>
167+
api
168+
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
169+
.reply(200, {
170+
data: mock.apps,
171+
})
172+
)
173+
.nock(`https://${developerHubBaseUrl}`, (api) =>
174+
api
175+
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
176+
.reply(200, {
177+
data: mock.apps,
178+
})
179+
)
180+
.nock(`https://${developerHubBaseUrl}`, (api) =>
181+
api
182+
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
183+
.reply(200, {
184+
data: mock.apps,
185+
})
186+
)
149187
.command([
150188
"app:update",
151189
"--app-manifest",
@@ -155,6 +193,7 @@ describe("app:update", () => {
155193
.do(({ stdout }) => expect(stdout).to.contain(messages.MAX_RETRY_LIMIT))
156194
.it("should fail with max retry message");
157195
});
196+
158197
describe("Update app with wrong `app version`", () => {
159198
test
160199
.stdout({ print: process.env.PRINT === "true" || false })
@@ -164,7 +203,7 @@ describe("app:update", () => {
164203
.stub(cliux, "inquire", async (...args: any) => {
165204
const [prompt]: any = args;
166205
const cases = {
167-
appUid: "app-uid-1",
206+
App: "App 1",
168207
Organization: "test org 1",
169208
appManifest: "test-manifest",
170209
};
@@ -176,6 +215,13 @@ describe("app:update", () => {
176215
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
177216
.reply(200, { organizations: mock.organizations })
178217
)
218+
.nock(`https://${developerHubBaseUrl}`, (api) =>
219+
api
220+
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
221+
.reply(200, {
222+
data: mock.apps,
223+
})
224+
)
179225
.nock(`https://${developerHubBaseUrl}`, (api) =>
180226
api.get("/manifests/app-uid-1").reply(200, {
181227
data: { ...manifestData, name: "test-app", version: 2 },
@@ -192,6 +238,7 @@ describe("app:update", () => {
192238
)
193239
.it("should fail with version miss match error message");
194240
});
241+
195242
describe("Update app wrong app-uid API failure", () => {
196243
test
197244
.stdout({ print: process.env.PRINT === "true" || false })
@@ -201,7 +248,7 @@ describe("app:update", () => {
201248
.stub(cliux, "inquire", async (...args: any) => {
202249
const [prompt]: any = args;
203250
const cases = {
204-
appUid: "app-uid-1",
251+
App: "App 1",
205252
Organization: "test org 1",
206253
appManifest: "test-manifest",
207254
};
@@ -213,6 +260,13 @@ describe("app:update", () => {
213260
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
214261
.reply(200, { organizations: mock.organizations })
215262
)
263+
.nock(`https://${developerHubBaseUrl}`, (api) =>
264+
api
265+
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
266+
.reply(200, {
267+
data: mock.apps,
268+
})
269+
)
216270
.nock(`https://${developerHubBaseUrl}`, (api) =>
217271
api.get("/manifests/app-uid-1").reply(200, {
218272
data: { ...manifestData, name: "test-app", version: 1 },
@@ -232,6 +286,7 @@ describe("app:update", () => {
232286
.do(({ stdout }) => expect(stdout).to.contain(messages.INVALID_APP_ID))
233287
.it("update app should fail with 400 status code");
234288
});
289+
235290
describe("Update app wrong org-uid API failure", () => {
236291
test
237292
.stdout({ print: process.env.PRINT === "true" || false })
@@ -241,7 +296,7 @@ describe("app:update", () => {
241296
.stub(cliux, "inquire", async (...args: any) => {
242297
const [prompt]: any = args;
243298
const cases = {
244-
appUid: "app-uid-1",
299+
App: "App 1",
245300
Organization: "test org 1",
246301
appManifest: "test-manifest",
247302
};
@@ -253,6 +308,13 @@ describe("app:update", () => {
253308
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
254309
.reply(200, { organizations: mock.organizations })
255310
)
311+
.nock(`https://${developerHubBaseUrl}`, (api) =>
312+
api
313+
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
314+
.reply(200, {
315+
data: mock.apps,
316+
})
317+
)
256318
.nock(`https://${developerHubBaseUrl}`, (api) =>
257319
api.get("/manifests/app-uid-1").reply(200, {
258320
data: { ...manifestData, name: "test-app", version: 1 },

test/unit/mock/common.mock.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,15 @@
88
"uid": "test-uid-2",
99
"name": "test org 2"
1010
}
11+
],
12+
"apps": [
13+
{
14+
"uid": "app-uid-1",
15+
"name": "App 1"
16+
},
17+
{
18+
"uid": "app-uid-2",
19+
"name": "App 2"
20+
}
1121
]
1222
}

0 commit comments

Comments
 (0)