fix(cardav): improve router security and test coverage

- Remove error message leakage (return generic 'Interner Fehler')
- Remove unused imports (str, collectErrors, MAX_TITLE, MAX_URL)
- Add _resetTestDatabase() for proper test cleanup
- Add test for populated accounts case with shape validation
- Import 'after' from node:test for proper teardown

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Ulas Kalayci
2026-05-04 16:51:21 +02:00
parent cf68bff25f
commit 930800eed9
3 changed files with 55 additions and 7 deletions
+14 -1
View File
@@ -1354,14 +1354,27 @@ function transaction(fn) {
return get().transaction(fn)();
}
let _originalDb = null;
/**
* ONLY FOR TESTING: Override the internal db instance
* @param {import('better-sqlite3').Database} testDb
*/
function _setTestDatabase(testDb) {
if (!_originalDb) _originalDb = db;
db = testDb;
}
/**
* ONLY FOR TESTING: Restore the original db instance
*/
function _resetTestDatabase() {
if (_originalDb) {
db = _originalDb;
_originalDb = null;
}
}
init(); // auto-initialise when module is first imported
export { init, get, transaction, currentVersion, getPath, backupToFile, restoreFromFile, MIGRATIONS, _setTestDatabase };
export { init, get, transaction, currentVersion, getPath, backupToFile, restoreFromFile, MIGRATIONS, _setTestDatabase, _resetTestDatabase };