@adobe/aio-cli-plugin-api-mesh 1.0.3-beta → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -7
- package/oclif.manifest.json +1 -1
- package/package.json +5 -2
- package/src/commands/api-mesh/__tests__/create.test.js +446 -33
- package/src/commands/api-mesh/__tests__/delete.test.js +267 -52
- package/src/commands/api-mesh/__tests__/describe.test.js +210 -40
- package/src/commands/api-mesh/__tests__/get.test.js +298 -36
- package/src/commands/api-mesh/__tests__/update.test.js +237 -61
- package/src/commands/api-mesh/create.js +92 -18
- package/src/commands/api-mesh/delete.js +76 -29
- package/src/commands/api-mesh/describe.js +27 -3
- package/src/commands/api-mesh/get.js +46 -26
- package/src/commands/api-mesh/source/__fixtures__/0.0.1-test-01.json +44 -0
- package/src/commands/api-mesh/source/__fixtures__/0.0.1-test-02.json +44 -0
- package/src/commands/api-mesh/source/__fixtures__/connectors-metadata.json +16 -0
- package/src/commands/api-mesh/source/__tests__/discover.test.js +58 -0
- package/src/commands/api-mesh/source/__tests__/get.test.js +123 -0
- package/src/commands/api-mesh/source/discover.js +70 -0
- package/src/commands/api-mesh/source/get.js +138 -0
- package/src/commands/api-mesh/update.js +54 -26
- package/src/constants.js +21 -0
- package/src/helpers.js +213 -44
- package/src/lib/devConsole.js +746 -0
- package/src/utils.js +18 -1
- package/src/classes/SchemaServiceClient.js +0 -416
|
@@ -10,95 +10,310 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
jest.mock('axios');
|
|
13
14
|
jest.mock('@adobe/aio-lib-env');
|
|
15
|
+
jest.mock('@adobe/aio-lib-ims');
|
|
14
16
|
jest.mock('@adobe/aio-cli-lib-console');
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
jest.mock('@adobe/aio-cli-lib-console', () => ({
|
|
18
|
+
init: jest.fn().mockResolvedValue(mockConsoleCLIInstance),
|
|
19
|
+
cleanStdOut: jest.fn(),
|
|
20
|
+
}));
|
|
21
|
+
jest.mock('../../../helpers', () => ({
|
|
22
|
+
initSdk: jest.fn().mockResolvedValue({}),
|
|
23
|
+
initRequestId: jest.fn().mockResolvedValue({}),
|
|
24
|
+
promptConfirm: jest.fn().mockResolvedValue(true),
|
|
25
|
+
}));
|
|
26
|
+
jest.mock('../../../lib/devConsole');
|
|
17
27
|
|
|
18
28
|
const mockConsoleCLIInstance = {};
|
|
19
29
|
|
|
20
|
-
const orgs = [{ id: '1234', code: 'CODE1234@AdobeOrg', name: 'ORG01', type: 'entp' }];
|
|
21
30
|
const selectedOrg = { id: '1234', code: 'CODE1234@AdobeOrg', name: 'ORG01', type: 'entp' };
|
|
22
31
|
|
|
23
|
-
const projects = [{ id: '5678', title: 'Project01' }];
|
|
24
32
|
const selectedProject = { id: '5678', title: 'Project01' };
|
|
25
33
|
|
|
26
|
-
const workspaces = [{ id: '123456789', title: 'Workspace01' }];
|
|
27
34
|
const selectedWorkspace = { id: '123456789', title: 'Workspace01' };
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
const DeleteCommand = require('../delete');
|
|
37
|
+
const { initSdk, initRequestId, promptConfirm } = require('../../../helpers');
|
|
38
|
+
const {
|
|
39
|
+
getMeshId,
|
|
40
|
+
deleteMesh,
|
|
41
|
+
getApiKeyCredential,
|
|
42
|
+
unsubscribeCredentialFromMeshService,
|
|
43
|
+
} = require('../../../lib/devConsole');
|
|
32
44
|
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
let logSpy = null;
|
|
46
|
+
let errorLogSpy = null;
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
mockConsoleCLIInstance.promptForSelectProject = jest.fn().mockResolvedValue(selectedProject);
|
|
48
|
+
let parseSpy = null;
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
50
|
+
const mockIgnoreCacheFlag = Promise.resolve(true);
|
|
51
|
+
const mockAutoApproveAction = Promise.resolve(false);
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
describe('delete command tests', () => {
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
initSdk.mockResolvedValue({
|
|
56
|
+
imsOrgId: selectedOrg.id,
|
|
57
|
+
projectId: selectedProject.id,
|
|
58
|
+
workspaceId: selectedWorkspace.id,
|
|
59
|
+
});
|
|
47
60
|
|
|
48
|
-
|
|
61
|
+
global.requestId = 'dummy_request_id';
|
|
49
62
|
|
|
50
|
-
jest.
|
|
51
|
-
|
|
52
|
-
jest.fn().mockResolvedValue({
|
|
53
|
-
res: true,
|
|
54
|
-
}),
|
|
55
|
-
),
|
|
56
|
-
}));
|
|
63
|
+
logSpy = jest.spyOn(DeleteCommand.prototype, 'log');
|
|
64
|
+
errorLogSpy = jest.spyOn(DeleteCommand.prototype, 'error');
|
|
57
65
|
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
getMeshId.mockResolvedValue('mesh_id');
|
|
67
|
+
deleteMesh.mockResolvedValue({ status: 'success' });
|
|
68
|
+
getApiKeyCredential.mockResolvedValue({
|
|
69
|
+
id_integration: 'dummy_integration_id',
|
|
70
|
+
client_id: 'dummy_client_id',
|
|
71
|
+
});
|
|
72
|
+
unsubscribeCredentialFromMeshService.mockResolvedValue(['dummy_service']);
|
|
60
73
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
parseSpy = jest.spyOn(DeleteCommand.prototype, 'parse');
|
|
75
|
+
parseSpy.mockResolvedValue({
|
|
76
|
+
args: {},
|
|
77
|
+
flags: {
|
|
78
|
+
ignoreCache: mockIgnoreCacheFlag,
|
|
79
|
+
autoConfirmAction: mockAutoApproveAction,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
64
82
|
});
|
|
65
83
|
|
|
66
84
|
afterEach(() => {
|
|
67
85
|
jest.restoreAllMocks();
|
|
68
86
|
});
|
|
69
87
|
|
|
88
|
+
test('snapshot delete command description', () => {
|
|
89
|
+
expect(DeleteCommand.description).toMatchInlineSnapshot(`"Delete the config of a given mesh"`);
|
|
90
|
+
expect(DeleteCommand.args).toMatchInlineSnapshot(`undefined`);
|
|
91
|
+
expect(DeleteCommand.flags).toMatchInlineSnapshot(`
|
|
92
|
+
Object {
|
|
93
|
+
"autoConfirmAction": Object {
|
|
94
|
+
"allowNo": false,
|
|
95
|
+
"char": "c",
|
|
96
|
+
"default": false,
|
|
97
|
+
"description": "Auto confirm action prompt. CLI will not check for user approval before executing the action.",
|
|
98
|
+
"parse": [Function],
|
|
99
|
+
"type": "boolean",
|
|
100
|
+
},
|
|
101
|
+
"ignoreCache": Object {
|
|
102
|
+
"allowNo": false,
|
|
103
|
+
"char": "i",
|
|
104
|
+
"default": false,
|
|
105
|
+
"description": "Ignore cache and force manual org -> project -> workspace selection",
|
|
106
|
+
"parse": [Function],
|
|
107
|
+
"type": "boolean",
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
`);
|
|
111
|
+
expect(DeleteCommand.aliases).toMatchInlineSnapshot(`Array []`);
|
|
112
|
+
});
|
|
113
|
+
|
|
70
114
|
test('should fail if mesh id is missing', async () => {
|
|
71
|
-
|
|
115
|
+
getMeshId.mockResolvedValue(null);
|
|
116
|
+
const runResult = DeleteCommand.run();
|
|
72
117
|
|
|
73
118
|
return runResult.catch(err => {
|
|
74
|
-
expect(err).
|
|
75
|
-
|
|
76
|
-
expect.stringMatching(/^Missing Mesh ID. Run aio api-mesh delete --help for more info/),
|
|
119
|
+
expect(err.message).toMatchInlineSnapshot(
|
|
120
|
+
`"Unable to delete. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again."`,
|
|
77
121
|
);
|
|
122
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
|
|
123
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
124
|
+
Array [
|
|
125
|
+
Array [
|
|
126
|
+
"Unable to delete. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again.",
|
|
127
|
+
],
|
|
128
|
+
]
|
|
129
|
+
`);
|
|
78
130
|
});
|
|
79
131
|
});
|
|
80
132
|
|
|
81
|
-
test('should delete if
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
expect.assertions(1);
|
|
86
|
-
const meshId = 'sample_merchant';
|
|
87
|
-
const runResult = DeleteCommand.run([meshId]);
|
|
133
|
+
test('should not delete if user prompt returns false', async () => {
|
|
134
|
+
promptConfirm.mockResolvedValueOnce(false);
|
|
135
|
+
|
|
136
|
+
const runResult = await DeleteCommand.run();
|
|
88
137
|
|
|
89
|
-
|
|
138
|
+
expect(runResult).toBe('Delete cancelled');
|
|
139
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
140
|
+
Array [
|
|
141
|
+
Array [
|
|
142
|
+
"Delete cancelled",
|
|
143
|
+
],
|
|
144
|
+
]
|
|
145
|
+
`);
|
|
146
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
|
|
90
147
|
});
|
|
91
148
|
|
|
92
|
-
test('should not
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
149
|
+
test('should not ask for prompt if autoConfirmAction is set', async () => {
|
|
150
|
+
parseSpy.mockResolvedValue({
|
|
151
|
+
args: {},
|
|
152
|
+
flags: {
|
|
153
|
+
ignoreCache: mockIgnoreCacheFlag,
|
|
154
|
+
autoConfirmAction: Promise.resolve(true),
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const runResult = await DeleteCommand.run();
|
|
159
|
+
|
|
160
|
+
expect(runResult).toMatchInlineSnapshot(`
|
|
161
|
+
Object {
|
|
162
|
+
"status": "success",
|
|
163
|
+
}
|
|
164
|
+
`);
|
|
165
|
+
expect(promptConfirm).not.toHaveBeenCalled();
|
|
166
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
167
|
+
Array [
|
|
168
|
+
Array [
|
|
169
|
+
"Successfully deleted mesh %s",
|
|
170
|
+
"mesh_id",
|
|
171
|
+
],
|
|
172
|
+
Array [
|
|
173
|
+
"Successfully unsubscribed API Key %s",
|
|
174
|
+
"dummy_client_id",
|
|
175
|
+
],
|
|
176
|
+
]
|
|
177
|
+
`);
|
|
178
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('should fail if mesh delete fails', async () => {
|
|
182
|
+
deleteMesh.mockRejectedValueOnce(new Error('mesh delete failed'));
|
|
183
|
+
|
|
184
|
+
const runResult = DeleteCommand.run();
|
|
185
|
+
|
|
186
|
+
await expect(runResult).rejects.toEqual(
|
|
187
|
+
new Error(
|
|
188
|
+
'Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id',
|
|
189
|
+
),
|
|
97
190
|
);
|
|
191
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
192
|
+
Array [
|
|
193
|
+
Array [
|
|
194
|
+
"mesh delete failed",
|
|
195
|
+
],
|
|
196
|
+
]
|
|
197
|
+
`);
|
|
198
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
199
|
+
Array [
|
|
200
|
+
Array [
|
|
201
|
+
"Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
|
|
202
|
+
],
|
|
203
|
+
]
|
|
204
|
+
`);
|
|
205
|
+
});
|
|
98
206
|
|
|
99
|
-
|
|
100
|
-
|
|
207
|
+
test('should delete mesh but fail to unsubscribe if unable to get api key', async () => {
|
|
208
|
+
getApiKeyCredential.mockRejectedValueOnce(new Error('unable to get api key'));
|
|
101
209
|
|
|
102
|
-
|
|
210
|
+
const runResult = DeleteCommand.run();
|
|
211
|
+
|
|
212
|
+
await expect(runResult).rejects.toEqual(
|
|
213
|
+
new Error(
|
|
214
|
+
'Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id',
|
|
215
|
+
),
|
|
216
|
+
);
|
|
217
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
218
|
+
Array [
|
|
219
|
+
Array [
|
|
220
|
+
"Successfully deleted mesh %s",
|
|
221
|
+
"mesh_id",
|
|
222
|
+
],
|
|
223
|
+
Array [
|
|
224
|
+
"unable to get api key",
|
|
225
|
+
],
|
|
226
|
+
]
|
|
227
|
+
`);
|
|
228
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
229
|
+
Array [
|
|
230
|
+
Array [
|
|
231
|
+
"Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
|
|
232
|
+
],
|
|
233
|
+
]
|
|
234
|
+
`);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test('should delete mesh but fail to unsubscribe if unsubscribe api failed', async () => {
|
|
238
|
+
unsubscribeCredentialFromMeshService.mockRejectedValueOnce(new Error('unsubscribe api failed'));
|
|
239
|
+
|
|
240
|
+
const runResult = DeleteCommand.run();
|
|
241
|
+
|
|
242
|
+
await expect(runResult).rejects.toEqual(
|
|
243
|
+
new Error(
|
|
244
|
+
'Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id',
|
|
245
|
+
),
|
|
246
|
+
);
|
|
247
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
248
|
+
Array [
|
|
249
|
+
Array [
|
|
250
|
+
"Successfully deleted mesh %s",
|
|
251
|
+
"mesh_id",
|
|
252
|
+
],
|
|
253
|
+
Array [
|
|
254
|
+
"unsubscribe api failed",
|
|
255
|
+
],
|
|
256
|
+
]
|
|
257
|
+
`);
|
|
258
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
259
|
+
Array [
|
|
260
|
+
Array [
|
|
261
|
+
"Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
|
|
262
|
+
],
|
|
263
|
+
]
|
|
264
|
+
`);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
test('should delete mesh and unsubscribe if correct args are provided', async () => {
|
|
268
|
+
const runResult = await DeleteCommand.run();
|
|
269
|
+
|
|
270
|
+
expect(initRequestId).toHaveBeenCalled();
|
|
271
|
+
expect(runResult).toMatchInlineSnapshot(`
|
|
272
|
+
Object {
|
|
273
|
+
"status": "success",
|
|
274
|
+
}
|
|
275
|
+
`);
|
|
276
|
+
expect(deleteMesh.mock.calls).toMatchInlineSnapshot(`
|
|
277
|
+
Array [
|
|
278
|
+
Array [
|
|
279
|
+
"1234",
|
|
280
|
+
"5678",
|
|
281
|
+
"123456789",
|
|
282
|
+
"mesh_id",
|
|
283
|
+
],
|
|
284
|
+
]
|
|
285
|
+
`);
|
|
286
|
+
expect(getApiKeyCredential.mock.calls).toMatchInlineSnapshot(`
|
|
287
|
+
Array [
|
|
288
|
+
Array [
|
|
289
|
+
"1234",
|
|
290
|
+
"5678",
|
|
291
|
+
"123456789",
|
|
292
|
+
],
|
|
293
|
+
]
|
|
294
|
+
`);
|
|
295
|
+
expect(unsubscribeCredentialFromMeshService.mock.calls).toMatchInlineSnapshot(`
|
|
296
|
+
Array [
|
|
297
|
+
Array [
|
|
298
|
+
"1234",
|
|
299
|
+
"5678",
|
|
300
|
+
"123456789",
|
|
301
|
+
"dummy_integration_id",
|
|
302
|
+
],
|
|
303
|
+
]
|
|
304
|
+
`);
|
|
305
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
306
|
+
Array [
|
|
307
|
+
Array [
|
|
308
|
+
"Successfully deleted mesh %s",
|
|
309
|
+
"mesh_id",
|
|
310
|
+
],
|
|
311
|
+
Array [
|
|
312
|
+
"Successfully unsubscribed API Key %s",
|
|
313
|
+
"dummy_client_id",
|
|
314
|
+
],
|
|
315
|
+
]
|
|
316
|
+
`);
|
|
317
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
|
|
103
318
|
});
|
|
104
319
|
});
|
|
@@ -11,69 +11,239 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
const mockConsoleCLIInstance = {};
|
|
14
|
+
|
|
15
|
+
jest.mock('axios');
|
|
14
16
|
jest.mock('@adobe/aio-lib-env');
|
|
15
17
|
jest.mock('@adobe/aio-cli-lib-console');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
jest.mock('@adobe/aio-lib-ims');
|
|
19
|
+
jest.mock('../../../helpers', () => ({
|
|
20
|
+
initSdk: jest.fn().mockResolvedValue({}),
|
|
21
|
+
initRequestId: jest.fn().mockResolvedValue({}),
|
|
22
|
+
}));
|
|
23
|
+
jest.mock('@adobe/aio-cli-lib-console', () => ({
|
|
24
|
+
init: jest.fn().mockResolvedValue(mockConsoleCLIInstance),
|
|
25
|
+
cleanStdOut: jest.fn(),
|
|
26
|
+
}));
|
|
27
|
+
jest.mock('../../../lib/devConsole');
|
|
18
28
|
|
|
19
|
-
const
|
|
20
|
-
const
|
|
29
|
+
const DescribeCommand = require('../describe');
|
|
30
|
+
const { initSdk, initRequestId } = require('../../../helpers');
|
|
31
|
+
const { describeMesh } = require('../../../lib/devConsole');
|
|
21
32
|
|
|
22
|
-
const
|
|
33
|
+
const selectedOrg = { id: '1234', code: 'CODE1234@AdobeOrg', name: 'ORG01', type: 'entp' };
|
|
34
|
+
const selectedProject = { id: '5678', title: 'Project01' };
|
|
23
35
|
const selectedWorkspace = { id: '123456789', title: 'Workspace01' };
|
|
24
36
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
mockConsoleCLIInstance.getOrganizations = jest.fn().mockResolvedValue(orgs);
|
|
30
|
-
mockConsoleCLIInstance.promptForSelectOrganization = jest.fn().mockResolvedValue(selectedOrg);
|
|
37
|
+
let logSpy = null;
|
|
38
|
+
let errorLogSpy = null;
|
|
39
|
+
let parseSpy = null;
|
|
31
40
|
|
|
32
|
-
|
|
33
|
-
mockConsoleCLIInstance.promptForSelectProject = jest.fn().mockResolvedValue(selectedProject);
|
|
41
|
+
const mockIgnoreCacheFlag = jest.fn().mockResolvedValue(true);
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
describe('describe command tests', () => {
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
describeMesh.mockResolvedValue({
|
|
46
|
+
meshId: 'dummy_meshId',
|
|
47
|
+
apiKey: 'dummy_apiKey',
|
|
48
|
+
});
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
initSdk.mockResolvedValue({
|
|
51
|
+
imsOrgId: selectedOrg.id,
|
|
52
|
+
projectId: selectedProject.id,
|
|
53
|
+
workspaceId: selectedWorkspace.id,
|
|
54
|
+
});
|
|
43
55
|
|
|
44
|
-
|
|
56
|
+
global.requestId = 'dummy_request_id';
|
|
45
57
|
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
logSpy = jest.spyOn(DescribeCommand.prototype, 'log');
|
|
59
|
+
errorLogSpy = jest.spyOn(DescribeCommand.prototype, 'error');
|
|
48
60
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
parseSpy = jest.spyOn(DescribeCommand.prototype, 'parse');
|
|
62
|
+
parseSpy.mockResolvedValue({
|
|
63
|
+
flags: {
|
|
64
|
+
ignoreCache: mockIgnoreCacheFlag,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
52
67
|
});
|
|
53
68
|
|
|
54
69
|
afterEach(() => {
|
|
55
70
|
jest.restoreAllMocks();
|
|
56
71
|
});
|
|
57
72
|
|
|
58
|
-
test('
|
|
59
|
-
|
|
73
|
+
test('snapshot describe command description', () => {
|
|
74
|
+
expect(DescribeCommand.description).toMatchInlineSnapshot(`"Get details of a mesh"`);
|
|
75
|
+
expect(DescribeCommand.args).toMatchInlineSnapshot(`undefined`);
|
|
76
|
+
expect(DescribeCommand.flags).toMatchInlineSnapshot(`
|
|
77
|
+
Object {
|
|
78
|
+
"ignoreCache": Object {
|
|
79
|
+
"allowNo": false,
|
|
80
|
+
"char": "i",
|
|
81
|
+
"default": false,
|
|
82
|
+
"description": "Ignore cache and force manual org -> project -> workspace selection",
|
|
83
|
+
"parse": [Function],
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
`);
|
|
88
|
+
expect(DescribeCommand.aliases).toMatchInlineSnapshot(`Array []`);
|
|
89
|
+
});
|
|
60
90
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
91
|
+
test('should error if describe api has failed', async () => {
|
|
92
|
+
describeMesh.mockRejectedValueOnce(new Error('describe api failed'));
|
|
93
|
+
|
|
94
|
+
const runResult = DescribeCommand.run();
|
|
95
|
+
|
|
96
|
+
await expect(runResult).rejects.toEqual(
|
|
97
|
+
new Error(
|
|
98
|
+
'Unable to get mesh details. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id',
|
|
99
|
+
),
|
|
100
|
+
);
|
|
101
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
102
|
+
Array [
|
|
103
|
+
Array [
|
|
104
|
+
"describe api failed",
|
|
105
|
+
],
|
|
106
|
+
]
|
|
107
|
+
`);
|
|
108
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
109
|
+
Array [
|
|
110
|
+
Array [
|
|
111
|
+
"Unable to get mesh details. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
|
|
112
|
+
],
|
|
113
|
+
]
|
|
114
|
+
`);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('should error if mesh details is missing from describe api response', async () => {
|
|
118
|
+
describeMesh.mockResolvedValueOnce(null);
|
|
119
|
+
|
|
120
|
+
const runResult = DescribeCommand.run();
|
|
121
|
+
|
|
122
|
+
await expect(runResult).rejects.toEqual(
|
|
123
|
+
new Error(
|
|
124
|
+
'Unable to get mesh details. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id',
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
128
|
+
Array [
|
|
129
|
+
Array [
|
|
130
|
+
"Unable to get mesh details",
|
|
131
|
+
],
|
|
132
|
+
]
|
|
133
|
+
`);
|
|
134
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
135
|
+
Array [
|
|
136
|
+
Array [
|
|
137
|
+
"Unable to get mesh details. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
|
|
138
|
+
],
|
|
139
|
+
]
|
|
140
|
+
`);
|
|
69
141
|
});
|
|
70
142
|
|
|
71
|
-
test('should
|
|
72
|
-
|
|
73
|
-
|
|
143
|
+
test('should error if mesh id is missing from describe api response', async () => {
|
|
144
|
+
describeMesh.mockResolvedValueOnce({});
|
|
145
|
+
|
|
146
|
+
const runResult = await DescribeCommand.run();
|
|
147
|
+
|
|
148
|
+
expect(runResult).toBe(undefined);
|
|
149
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
|
|
150
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
151
|
+
Array [
|
|
152
|
+
Array [
|
|
153
|
+
"Unable to get mesh details. Please check the details and try again. RequestId: dummy_request_id",
|
|
154
|
+
Object {
|
|
155
|
+
"exit": false,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
]
|
|
159
|
+
`);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test('should not fail if api key is missing from mesh details', async () => {
|
|
163
|
+
describeMesh.mockResolvedValueOnce({ meshId: 'dummy_meshId' });
|
|
164
|
+
|
|
165
|
+
const runResult = await DescribeCommand.run();
|
|
166
|
+
|
|
167
|
+
expect(runResult).toMatchInlineSnapshot(`
|
|
168
|
+
Object {
|
|
169
|
+
"meshId": "dummy_meshId",
|
|
170
|
+
}
|
|
171
|
+
`);
|
|
172
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
173
|
+
Array [
|
|
174
|
+
Array [
|
|
175
|
+
"Successfully retrieved mesh details
|
|
176
|
+
",
|
|
177
|
+
],
|
|
178
|
+
Array [
|
|
179
|
+
"Org ID: %s",
|
|
180
|
+
"1234",
|
|
181
|
+
],
|
|
182
|
+
Array [
|
|
183
|
+
"Project ID: %s",
|
|
184
|
+
"5678",
|
|
185
|
+
],
|
|
186
|
+
Array [
|
|
187
|
+
"Workspace ID: %s",
|
|
188
|
+
"123456789",
|
|
189
|
+
],
|
|
190
|
+
Array [
|
|
191
|
+
"Mesh ID: %s",
|
|
192
|
+
"dummy_meshId",
|
|
193
|
+
],
|
|
194
|
+
]
|
|
195
|
+
`);
|
|
196
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
|
|
197
|
+
});
|
|
74
198
|
|
|
199
|
+
test('should succeed if valid details are provided', async () => {
|
|
75
200
|
const runResult = await DescribeCommand.run();
|
|
76
201
|
|
|
77
|
-
|
|
202
|
+
expect(initRequestId).toHaveBeenCalled();
|
|
203
|
+
expect(describeMesh).toHaveBeenCalledWith(
|
|
204
|
+
selectedOrg.id,
|
|
205
|
+
selectedProject.id,
|
|
206
|
+
selectedWorkspace.id,
|
|
207
|
+
);
|
|
208
|
+
expect(runResult).toMatchInlineSnapshot(`
|
|
209
|
+
Object {
|
|
210
|
+
"apiKey": "dummy_apiKey",
|
|
211
|
+
"meshId": "dummy_meshId",
|
|
212
|
+
}
|
|
213
|
+
`);
|
|
214
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
215
|
+
Array [
|
|
216
|
+
Array [
|
|
217
|
+
"Successfully retrieved mesh details
|
|
218
|
+
",
|
|
219
|
+
],
|
|
220
|
+
Array [
|
|
221
|
+
"Org ID: %s",
|
|
222
|
+
"1234",
|
|
223
|
+
],
|
|
224
|
+
Array [
|
|
225
|
+
"Project ID: %s",
|
|
226
|
+
"5678",
|
|
227
|
+
],
|
|
228
|
+
Array [
|
|
229
|
+
"Workspace ID: %s",
|
|
230
|
+
"123456789",
|
|
231
|
+
],
|
|
232
|
+
Array [
|
|
233
|
+
"Mesh ID: %s",
|
|
234
|
+
"dummy_meshId",
|
|
235
|
+
],
|
|
236
|
+
Array [
|
|
237
|
+
"API Key: %s",
|
|
238
|
+
"dummy_apiKey",
|
|
239
|
+
],
|
|
240
|
+
Array [
|
|
241
|
+
"Mesh Endpoint: %s
|
|
242
|
+
",
|
|
243
|
+
"https://graph.adobe.io/api/dummy_meshId/graphql?api_key=dummy_apiKey",
|
|
244
|
+
],
|
|
245
|
+
]
|
|
246
|
+
`);
|
|
247
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
|
|
78
248
|
});
|
|
79
249
|
});
|