@@ -41,7 +41,7 @@ test.group('File Driver | Prune', () => {
4141 assert . isTrue ( await fs . exists ( 'foo4' ) )
4242 } )
4343
44- test ( 'continue if invalid file is inside the cache directory ' , async ( {
44+ test ( 'delete corrupted cache files (invalid JSON) during prune ' , async ( {
4545 assert,
4646 fs,
4747 cleanup,
@@ -59,11 +59,28 @@ test.group('File Driver | Prune', () => {
5959
6060 await sleep ( 1000 )
6161
62- assert . isTrue ( await fs . exists ( 'foo' ) )
62+ assert . isFalse ( await fs . exists ( 'foo' ) )
6363 assert . isFalse ( await fs . exists ( 'foo2' ) )
6464 assert . isFalse ( await fs . exists ( 'foo3/1' ) )
6565 } )
6666
67+ test ( 'delete empty cache files during prune' , async ( { assert, fs, cleanup } ) => {
68+ const driver = new FileDriver ( {
69+ pruneInterval : 500 ,
70+ directory : fileURLToPath ( BASE_URL ) ,
71+ } )
72+
73+ cleanup ( ( ) => driver . disconnect ( ) )
74+
75+ await fs . create ( 'emptyFile' , '' )
76+ await driver . set ( 'validKey' , 'bar' , 300 )
77+
78+ await sleep ( 1000 )
79+
80+ assert . isFalse ( await fs . exists ( 'emptyFile' ) )
81+ assert . isFalse ( await fs . exists ( 'validKey' ) )
82+ } )
83+
6784 test ( 'use configured logger' , async ( { assert, fs, cleanup } ) => {
6885 const logger = testLogger ( )
6986 const driver = new FileDriver ( {
0 commit comments