1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Cleanups in the opfs-sahpool VFS pause/unpause feature and its tests.

FossilOrigin-Name: 184ba37702f63196deca91d273e798ca895fbb301938e6264bc82815a4e33149
This commit is contained in:
stephan
2025-01-31 14:25:38 +00:00
parent d4bfa3465e
commit 654c94d683
4 changed files with 87 additions and 39 deletions

View File

@ -3155,12 +3155,23 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
T.assert(1 === u1.getFileCount());
db = new u2.OpfsSAHPoolDb(dbName);
T.assert(1 === u1.getFileCount())
.mustThrow(()=>u2.pauseVfs(), "Cannot pause VFS with opened db.");
.mustThrowMatching(
()=>u1.pauseVfs(),
(err)=>{
return capi.SQLITE_MISUSE===err.resultCode
&& /^SQLITE_MISUSE: Cannot pause VFS /.test(err.message);
},
"Cannot pause VFS with opened db."
);
db.close();
T.assert( u2===u2.pauseVfs() )
.assert( u2.isPaused() )
.assert( 0===capi.sqlite3_vfs_find(u2.vfsName) )
.mustThrowMatching(()=>new u2.OpfsSAHPoolDb(dbName),
/.+no such vfs: .+/,
"VFS is not available")
.assert( u2===await u2.unpauseVfs() )
.assert( u2===await u1.unpauseVfs(), "unpause is a no-op if the VFS is not paused" )
.assert( 0!==capi.sqlite3_vfs_find(u2.vfsName) );
const fileNames = u1.getFileNames();
T.assert(1 === fileNames.length)