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
@@ -1443,6 +1444,19 @@ describe('CliRepl', function () {
14431444 )
14441445 ) ;
14451446 } ) ;
1447+
1448+ it ( 'can set log retention days' , async function ( ) {
1449+ const testRetentionDays = 123 ;
1450+ cliRepl . config . logRetentionDays = testRetentionDays ;
1451+ await cliRepl . start ( await testServer . connectionString ( ) , { } ) ;
1452+
1453+ expect ( cliRepl . getConfig ( 'logRetentionDays' ) ) . equals (
1454+ testRetentionDays
1455+ ) ;
1456+ expect ( cliRepl . logManager ?. _options . retentionDays ) . equals (
1457+ testRetentionDays
1458+ ) ;
1459+ } ) ;
14461460 } ) ;
14471461
14481462 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