@@ -92,6 +92,7 @@ for (const { runnerEnv, ErrorConstructor, message } of [
9292 cleanupDatabaseClusterDirectory (
9393 createTestConfig ( { dbLocation } ) ,
9494 getRecordingLogger ( messages ) ,
95+ { } ,
9596 ( ) => {
9697 throw new Error ( rmSyncError ) ;
9798 } ,
@@ -112,6 +113,33 @@ for (const { runnerEnv, ErrorConstructor, message } of [
112113 } ) ;
113114}
114115
116+ test ( "cleanupDatabaseClusterDirectory can disable warning with options" , async ( t ) => {
117+ await withTmpDir ( async ( tmpDir : string ) => {
118+ const dbLocation = path . resolve ( tmpDir , "dbs" ) ;
119+ fs . mkdirSync ( dbLocation , { recursive : true } ) ;
120+
121+ const fileToCleanUp = path . resolve ( dbLocation , "something-to-cleanup.txt" ) ;
122+ fs . writeFileSync ( fileToCleanUp , "" ) ;
123+
124+ const messages : LoggedMessage [ ] = [ ] ;
125+ cleanupDatabaseClusterDirectory (
126+ createTestConfig ( { dbLocation } ) ,
127+ getRecordingLogger ( messages ) ,
128+ { disableExistingDirectoryWarning : true } ,
129+ ) ;
130+
131+ // Should only have the info message, not the warning
132+ t . is ( messages . length , 1 ) ;
133+ t . is ( messages [ 0 ] . type , "info" ) ;
134+ t . is (
135+ messages [ 0 ] . message ,
136+ `Cleaned up database cluster directory ${ dbLocation } .` ,
137+ ) ;
138+
139+ t . false ( fs . existsSync ( fileToCleanUp ) ) ;
140+ } ) ;
141+ } ) ;
142+
115143type PackInfo = {
116144 kind : "query" | "library" ;
117145 packinfoContents ?: string ;
0 commit comments