mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
integration-test: Allow for in-memory database
This commit is contained in:
parent
1542eb14b3
commit
64f99ba637
@ -45,7 +45,8 @@
|
||||
"prepare-dist": "rimraf ./dist && tsc && tsx ./bin/copy-dist.ts",
|
||||
"update-build-info": "tsx bin/update-build-info.ts",
|
||||
"errors": "tsc --watch --noEmit",
|
||||
"integration-edit-db": "cross-env TRILIUM_INTEGRATION_TEST=edit TRILIUM_PORT=8081 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/www.ts"
|
||||
"integration-edit-db": "cross-env TRILIUM_INTEGRATION_TEST=edit TRILIUM_PORT=8081 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/www.ts",
|
||||
"integration-mem-db": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/www.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@braintree/sanitize-url": "^7.1.0",
|
||||
|
@ -14,7 +14,18 @@ import ws from "./ws.js";
|
||||
import becca_loader from "../becca/becca_loader.js";
|
||||
import entity_changes from "./entity_changes.js";
|
||||
|
||||
const dbConnection: DatabaseType = new Database(dataDir.DOCUMENT_PATH);
|
||||
function buildDatabase(path: string) {
|
||||
if (process.env.TRILIUM_INTEGRATION_TEST === "memory") {
|
||||
// This allows a database that is read normally but is kept in memory and discards all modifications.
|
||||
const dbBuffer = fs.readFileSync(path);
|
||||
return new Database(dbBuffer);
|
||||
}
|
||||
|
||||
return new Database(dataDir.DOCUMENT_PATH);
|
||||
}
|
||||
|
||||
const dbConnection: DatabaseType = buildDatabase(dataDir.DOCUMENT_PATH);
|
||||
|
||||
if (!process.env.TRILIUM_INTEGRATION_TEST) {
|
||||
dbConnection.pragma('journal_mode = WAL');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user