@@ -71,7 +71,7 @@ test("Command builder", async (t) => {
7171 t . is ( result , cliStub , "Builder returns cli instance" ) ;
7272 t . is ( cliStub . demandCommand . callCount , 1 , "demandCommand called once" ) ;
7373 t . is ( cliStub . command . callCount , 1 , "command called once" ) ;
74- t . is ( cliStub . example . callCount , 1 , "example called once " ) ;
74+ t . is ( cliStub . example . callCount , 2 , "example called twice " ) ;
7575} ) ;
7676
7777test . serial ( "ui5 cache clean: nothing to clean" , async ( t ) => {
@@ -253,3 +253,32 @@ test.serial("ui5 cache clean: uses config.getUi5DataDir when no env var", async
253253 }
254254 }
255255} ) ;
256+
257+ test . serial ( "ui5 cache clean --no-interactive: skips confirmation prompt" , async ( t ) => {
258+ const { cache, argv, stderrWriteStub, frameworkCacheCleanCache, frameworkCacheGetCacheInfo,
259+ buildCacheCleanCache, buildCacheGetCacheInfo, mockRLInterface} = t . context ;
260+
261+ frameworkCacheGetCacheInfo . resolves ( { path : "framework/" , size : 10 * 1024 * 1024 , type : "directory" } ) ;
262+ buildCacheGetCacheInfo . resolves ( {
263+ path : "buildCache/v0_7 (database records)" , size : 5 * 1024 * 1024 , type : "database"
264+ } ) ;
265+
266+ frameworkCacheCleanCache . resolves ( { path : "framework" , type : "framework" , size : 10 * 1024 * 1024 } ) ;
267+ buildCacheCleanCache . resolves ( { path : "buildCache/v0_7" , type : "buildCache" , size : 5 * 1024 * 1024 } ) ;
268+
269+ argv [ "_" ] = [ "cache" , "clean" ] ;
270+ argv [ "interactive" ] = false ;
271+ await cache . handler ( argv ) ;
272+
273+ // Confirmation should NOT be asked
274+ t . is ( mockRLInterface . question . callCount , 0 , "Should not ask for confirmation in non-interactive mode" ) ;
275+
276+ // Cleanup should still proceed
277+ t . is ( frameworkCacheCleanCache . callCount , 1 , "frameworkCache.cleanCache should be called" ) ;
278+ t . is ( buildCacheCleanCache . callCount , 1 , "buildCache.cleanCache should be called" ) ;
279+
280+ // Check output
281+ const allOutput = stderrWriteStub . args . map ( ( a ) => a [ 0 ] ) . join ( "" ) ;
282+ t . true ( allOutput . includes ( "following items from cache will be removed" ) , "Shows items to be removed" ) ;
283+ t . true ( allOutput . includes ( "Success" ) , "Shows success message" ) ;
284+ } ) ;
0 commit comments