File tree Expand file tree Collapse file tree 4 files changed +23
-1
lines changed
Expand file tree Collapse file tree 4 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,7 @@ describe('CliRepl', function () {
323323 'updateURL' ,
324324 'disableLogging' ,
325325 'logLocation' ,
326+ 'logRetentionDays' ,
326327 ] satisfies ( keyof CliUserConfig ) [ ] ) ;
327328 } ) ;
328329
@@ -1436,6 +1437,19 @@ describe('CliRepl', function () {
14361437 expect ( cliRepl . getConfig ( 'logLocation' ) ) . is . true ;
14371438 expect ( cliRepl . logWriter ?. logFilePath ) . equals ( testPath ) ;
14381439 } ) ;
1440+
1441+ it ( 'can set log retention days' , async function ( ) {
1442+ const testRetentionDays = 123 ;
1443+ cliRepl . config . logRetentionDays = testRetentionDays ;
1444+ await cliRepl . start ( await testServer . connectionString ( ) , { } ) ;
1445+
1446+ expect ( cliRepl . getConfig ( 'logRetentionDays' ) ) . equals (
1447+ testRetentionDays
1448+ ) ;
1449+ expect ( cliRepl . logManager ?. _options . retentionDays ) . equals (
1450+ testRetentionDays
1451+ ) ;
1452+ } ) ;
14391453 } ) ;
14401454
14411455 it ( 'times out fast' , async function ( ) {
Original file line number Diff line number Diff line change @@ -259,7 +259,7 @@ export class CliRepl implements MongoshIOProvider {
259259 directory :
260260 ( await this . getConfig ( 'logLocation' ) ) ||
261261 this . shellHomeDirectory . localPath ( '.' ) ,
262- retentionDays : 30 ,
262+ retentionDays : await this . getConfig ( 'logRetentionDays' ) ,
263263 maxLogFileCount : + (
264264 process . env . MONGOSH_TEST_ONLY_MAX_LOG_FILE_COUNT || 100
265265 ) ,
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ describe('config validation', function () {
2525 expect ( await validate ( 'historyLength' , 0 ) ) . to . equal ( null ) ;
2626 expect ( await validate ( 'historyLength' , 1 ) ) . to . equal ( null ) ;
2727 expect ( await validate ( 'historyLength' , Infinity ) ) . to . equal ( null ) ;
28+ expect ( await validate ( 'logRetentionDays' , 'foo' ) ) . to . equal (
29+ 'logRetentionDays must be a positive integer'
30+ ) ;
31+ expect ( await validate ( 'logRetentionDays' , - 1 ) ) . to . equal (
32+ 'logRetentionDays must be a positive integer'
33+ ) ;
2834 expect ( await validate ( 'showStackTraces' , 'foo' ) ) . to . equal (
2935 'showStackTraces must be a boolean'
3036 ) ;
Original file line number Diff line number Diff line change @@ -509,6 +509,7 @@ export class CliUserConfig extends SnippetShellUserConfig {
509509 updateURL = 'https://downloads.mongodb.com/compass/mongosh.json' ;
510510 disableLogging = false ;
511511 logLocation : string | undefined = undefined ;
512+ logRetentionDays = 30 ;
512513}
513514
514515export class CliUserConfigValidator extends SnippetShellUserConfigValidator {
@@ -531,6 +532,7 @@ export class CliUserConfigValidator extends SnippetShellUserConfigValidator {
531532 return null ;
532533 case 'inspectDepth' :
533534 case 'historyLength' :
535+ case 'logRetentionDays' :
534536 if ( typeof value !== 'number' || value < 0 ) {
535537 return `${ key } must be a positive integer` ;
536538 }
You can’t perform that action at this time.
0 commit comments