diff options
author | stephan <stephan@noemail.net> | 2023-07-30 03:54:10 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2023-07-30 03:54:10 +0000 |
commit | f0c701c4109629cfbf35d55b708403807666c6fb (patch) | |
tree | cf17b054233289b1a2253dac1efe7d75365f1e81 /ext/wasm/tester1.c-pp.js | |
parent | b47e1c78668f32f7786f0184955ce1ec10777ba6 (diff) | |
download | sqlite-f0c701c4109629cfbf35d55b708403807666c6fb.tar.gz sqlite-f0c701c4109629cfbf35d55b708403807666c6fb.zip |
Add tests for SAHPoolUtil.exportFile() and importDb().
FossilOrigin-Name: 4aa88b8fb1c99137ed7531e5c82a241738a2b0554f7af82c0ed0ce8d16a0879a
Diffstat (limited to 'ext/wasm/tester1.c-pp.js')
-rw-r--r-- | ext/wasm/tester1.c-pp.js | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index db4b50f4b..c1b16d5e8 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -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 |