Skip to content

Commit 5c4da2b

Browse files
committed
fix: test cases & updated talismanrc
1 parent b95884e commit 5c4da2b

2 files changed

Lines changed: 62 additions & 38 deletions

File tree

.talismanrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
fileignoreconfig:
22
- filename: package-lock.json
3-
checksum: 64a89b20371afdaaf3e901f82d7d82e342d331015efba222a32032a58063780b
3+
checksum: e3505ef86a0af5ebb0841334a73ecb49161ebe0fa15e41b5afb2b2734e54086c
44
- filename: pnpm-lock.yaml
5-
checksum: d9ad2eb48406e93e01b9db255da99bed98e29eb6db1fb5821b50f7e60b6f3efa
5+
checksum: c8871b2dbcb3ccb9824b0fdc6e8227ea5b9f4eda875b20e44720b10626db5291
66
- filename: packages/contentstack-import-setup/test/unit/backup-handler.test.ts
77
checksum: 0582d62b88834554cf12951c8690a73ef3ddbb78b82d2804d994cf4148e1ef93
88
- filename: packages/contentstack-import-setup/test/config.json

packages/contentstack-config/test/unit/commands/log.test.ts

Lines changed: 60 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ describe('Log Commands', () => {
4848
expect(
4949
setStub.calledWith('log', {
5050
level: 'debug',
51-
path: './logs/app.log',
52-
showConsoleLogs: false,
51+
path: expectedAbsolutePath, // Should be directory path, not file path
52+
'show-console-logs': false,
5353
}),
5454
).to.be.true;
5555

@@ -88,13 +88,9 @@ describe('Log Commands', () => {
8888

8989
await cmd.run();
9090

91-
expect(
92-
setStub.calledWith('log', {
93-
level: 'info',
94-
path: './custom/logs/app.log',
95-
showConsoleLogs: false,
96-
}),
97-
).to.be.true;
91+
// Should call set even when no flags are provided
92+
expect(setStub.called).to.be.true;
93+
expect(setStub.calledWith('log', {})).to.be.true;
9894

9995
// Should not display any success messages when no flags are provided
10096
expect(successMessage.length).to.equal(0);
@@ -121,8 +117,8 @@ describe('Log Commands', () => {
121117
expect(
122118
setStub.calledWith('log', {
123119
level: 'warn',
124-
path: './existing/logs/app.log',
125-
showConsoleLogs: false,
120+
path: existingPath, // Should preserve existing path unchanged
121+
'show-console-logs': true, // Should preserve existing console logs setting
126122
}),
127123
).to.be.true;
128124

@@ -153,8 +149,8 @@ describe('Log Commands', () => {
153149
expect(
154150
setStub.calledWith('log', {
155151
level: 'error',
156-
path: './new/logs/app.log',
157-
showConsoleLogs: false,
152+
path: expectedAbsolutePath,
153+
'show-console-logs': false,
158154
}),
159155
).to.be.true;
160156

@@ -176,9 +172,9 @@ describe('Log Commands', () => {
176172

177173
expect(
178174
setStub.calledWith('log', {
179-
level: 'info',
180-
path: './logs/app.log',
181-
showConsoleLogs: true,
175+
level: 'debug',
176+
path: './existing.log',
177+
'show-console-logs': true,
182178
}),
183179
).to.be.true;
184180

@@ -201,8 +197,7 @@ describe('Log Commands', () => {
201197
expect(
202198
setStub.calledWith('log', {
203199
level: 'info',
204-
path: './logs/app.log',
205-
showConsoleLogs: false,
200+
'show-console-logs': false,
206201
}),
207202
).to.be.true;
208203

@@ -232,8 +227,8 @@ describe('Log Commands', () => {
232227
expect(
233228
setStub.calledWith('log', {
234229
level: 'warn',
235-
path: './logs/warnings.log',
236-
showConsoleLogs: true,
230+
path: expectedAbsolutePath,
231+
'show-console-logs': true,
237232
}),
238233
).to.be.true;
239234

@@ -262,9 +257,8 @@ describe('Log Commands', () => {
262257

263258
expect(
264259
setStub.calledWith('log', {
265-
level: 'info',
266-
path: './logs/app.log',
267-
showConsoleLogs: false,
260+
path: expectedDirectoryPath,
261+
'show-console-logs': false,
268262
}),
269263
).to.be.true;
270264
});
@@ -311,12 +305,22 @@ describe('Log Commands', () => {
311305
await cmd.run();
312306

313307
expect(tableMessage).to.have.length(1);
314-
expect(tableMessage[0].headers).to.deep.equal([{ value: 'Log Level' }, { value: 'Log Path' }, { value: 'Show Console Logs' }]);
308+
expect(tableMessage[0].headers).to.deep.equal([
309+
{ value: 'Setting' },
310+
{ value: 'Value' }
311+
]);
315312
expect(tableMessage[0].data).to.deep.equal([
316313
{
317-
'Log Level': 'debug',
318-
'Log Path': './logs/app.log',
319-
'Show Console Logs': 'Not set',
314+
'Setting': 'Log Level',
315+
'Value': 'debug'
316+
},
317+
{
318+
'Setting': 'Log Path',
319+
'Value': expectedAbsolutePath
320+
},
321+
{
322+
'Setting': 'Show Console Logs',
323+
'Value': 'false'
320324
},
321325
]);
322326
});
@@ -328,12 +332,22 @@ describe('Log Commands', () => {
328332
await cmd.run();
329333

330334
expect(tableMessage).to.have.length(1);
331-
expect(tableMessage[0].headers).to.deep.equal([{ value: 'Log Level' }, { value: 'Log Path' }, { value: 'Show Console Logs' }]);
335+
expect(tableMessage[0].headers).to.deep.equal([
336+
{ value: 'Setting' },
337+
{ value: 'Value' }
338+
]);
332339
expect(tableMessage[0].data).to.deep.equal([
333340
{
334-
'Log Level': 'info',
335-
'Log Path': 'Not set',
336-
'Show Console Logs': 'Not set',
341+
'Setting': 'Log Level',
342+
'Value': 'info'
343+
},
344+
{
345+
'Setting': 'Log Path',
346+
'Value': LOG_CONFIG_DEFAULTS.PATH
347+
},
348+
{
349+
'Setting': 'Show Console Logs',
350+
'Value': 'false'
337351
},
338352
]);
339353
});
@@ -348,12 +362,22 @@ describe('Log Commands', () => {
348362
await cmd.run();
349363

350364
expect(tableMessage).to.have.length(1);
351-
expect(tableMessage[0].headers).to.deep.equal([{ value: 'Log Level' }, { value: 'Log Path' }, { value: 'Show Console Logs' }]);
365+
expect(tableMessage[0].headers).to.deep.equal([
366+
{ value: 'Setting' },
367+
{ value: 'Value' }
368+
]);
352369
expect(tableMessage[0].data).to.deep.equal([
353370
{
354-
'Log Level': 'Not set',
355-
'Log Path': './custom/logs/app.log',
356-
'Show Console Logs': 'Not set',
371+
'Setting': 'Log Level',
372+
'Value': LOG_CONFIG_DEFAULTS.LEVEL
373+
},
374+
{
375+
'Setting': 'Log Path',
376+
'Value': expectedAbsolutePath
377+
},
378+
{
379+
'Setting': 'Show Console Logs',
380+
'Value': 'false'
357381
},
358382
]);
359383
});
@@ -607,4 +631,4 @@ describe('Log Commands', () => {
607631
expect(successMessage.some(msg => msg.includes('CLI_CONFIG_LOG_PATH_SET'))).to.be.true;
608632
});
609633
});
610-
});
634+
});

0 commit comments

Comments
 (0)