Page MenuHomePhabricator

D8558.diff
No OneTemporary

D8558.diff

diff --git a/web/database/db-module.test.js b/web/database/db-module.test.js
new file mode 100644
--- /dev/null
+++ b/web/database/db-module.test.js
@@ -0,0 +1,31 @@
+// @flow
+
+import { getDatabaseModule } from './db-module.js';
+import { clearSensitiveData, exportDatabaseContent } from './utils/db-utils.js';
+
+const FILE_PATH = 'test.sqlite';
+
+const TEST_KEY = 'a';
+const TEST_VAL = 'b';
+
+describe('Database Module', () => {
+ it('should construct a Database', async () => {
+ const module = getDatabaseModule();
+ const queryExecutor = new module.SQLiteQueryExecutor(FILE_PATH);
+ expect(queryExecutor).not.toBe(undefined);
+ });
+
+ it('should handle clearing sensitive data', async () => {
+ const module = getDatabaseModule();
+ const queryExecutor = new module.SQLiteQueryExecutor(FILE_PATH);
+
+ expect(() => exportDatabaseContent(module, FILE_PATH)).not.toThrow();
+ expect(() => queryExecutor.setMetadata(TEST_KEY, TEST_VAL)).not.toThrow();
+ expect(module.FS.stat(FILE_PATH)).toBeDefined();
+
+ clearSensitiveData(module, FILE_PATH, queryExecutor);
+ expect(() => exportDatabaseContent(module, FILE_PATH)).toThrow();
+ expect(() => queryExecutor.setMetadata(TEST_KEY, TEST_VAL)).toThrow();
+ expect(() => module.FS.stat(FILE_PATH)).toThrow();
+ });
+});
diff --git a/web/database/sql-js.test.js b/web/database/sql-js.test.js
deleted file mode 100644
--- a/web/database/sql-js.test.js
+++ /dev/null
@@ -1,29 +0,0 @@
-// @flow
-
-import initSqlJs from 'sql.js';
-
-import {
- getSQLiteDBVersion,
- setSQLiteDBVersion,
-} from './queries/db-queries.js';
-
-describe('sql.js', () => {
- it('should construct a Database', async () => {
- const SQL = await initSqlJs();
- const db = new SQL.Database();
- expect(db).not.toBe(undefined);
- });
-
- it('should return default database version', async () => {
- const SQL = await initSqlJs();
- const db = new SQL.Database();
- expect(getSQLiteDBVersion(db)).toBe(0);
- });
-
- it('should update database version', async () => {
- const SQL = await initSqlJs();
- const db = new SQL.Database();
- setSQLiteDBVersion(db, 10);
- expect(getSQLiteDBVersion(db)).toBe(10);
- });
-});

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 1:57 PM (19 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2571059
Default Alt Text
D8558.diff (2 KB)

Event Timeline