mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
Add tests for SAHPoolUtil.exportFile() and importDb().
FossilOrigin-Name: 4aa88b8fb1c99137ed7531e5c82a241738a2b0554f7af82c0ed0ce8d16a0879a
This commit is contained in:
@ -353,7 +353,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
||||
const sahPoolConfig = {
|
||||
name: 'opfs-sahpool-tester1',
|
||||
clearOnInit: true,
|
||||
initialCapacity: 3
|
||||
initialCapacity: 6
|
||||
};
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// End of infrastructure setup. Now define the tests...
|
||||
@ -3076,7 +3076,24 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
||||
T.assert(1 === fileNames.length)
|
||||
.assert(dbName === fileNames[0])
|
||||
.assert(1 === u1.getFileCount())
|
||||
.assert(true === u1.unlink(dbName))
|
||||
|
||||
if(1){ // test exportFile() and importDb()
|
||||
const dbytes = u1.exportFile(dbName);
|
||||
T.assert(dbytes.length >= 4096);
|
||||
const dbName2 = '/exported.db';
|
||||
u1.importDb(dbName2, dbytes);
|
||||
T.assert( 2 == u1.getFileCount() );
|
||||
let db2 = new u1.OpfsSAHPoolDb(dbName2);
|
||||
T.assert(db2 instanceof sqlite3.oo1.DB)
|
||||
.assert(3 === db2.selectValue('select count(*) from t'));
|
||||
db2.close();
|
||||
T.assert(true === u1.unlink(dbName2))
|
||||
.assert(false === u1.unlink(dbName2))
|
||||
.assert(1 === u1.getFileCount())
|
||||
.assert(1 === u1.getFileNames().length);
|
||||
}
|
||||
|
||||
T.assert(true === u1.unlink(dbName))
|
||||
.assert(false === u1.unlink(dbName))
|
||||
.assert(0 === u1.getFileCount())
|
||||
.assert(0 === u1.getFileNames().length);
|
||||
@ -3089,6 +3106,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
||||
log("Installed second SAH instance as",conf2.name);
|
||||
T.assert(0 === POther.getFileCount())
|
||||
.assert(true === await POther.removeVfs());
|
||||
|
||||
if(0){
|
||||
/* Enable this block to inspect vfs's contents via the dev
|
||||
console or OPFS Explorer browser extension. The
|
||||
|
Reference in New Issue
Block a user