Page MenuHomePhabricator

D11241.id37809.diff
No OneTemporary

D11241.id37809.diff

diff --git a/web/database/queries/communities-queries.test.js b/web/database/queries/communities-queries.test.js
--- a/web/database/queries/communities-queries.test.js
+++ b/web/database/queries/communities-queries.test.js
@@ -41,10 +41,12 @@
beforeEach(() => {
if (!dbModule) {
- return;
+ throw new Error('Database module is missing');
}
-
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLite Query Executor is missing');
+ }
queryExecutor?.replaceCommunity(
convertCommunityInfoToClientDBCommunityInfo({
communityInfo: TEST_COMMUNITY_1,
diff --git a/web/database/queries/draft-queries.test.js b/web/database/queries/draft-queries.test.js
--- a/web/database/queries/draft-queries.test.js
+++ b/web/database/queries/draft-queries.test.js
@@ -14,7 +14,13 @@
});
beforeEach(() => {
+ if (!dbModule) {
+ throw new Error('Database module is missing');
+ }
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLite Query Executor is missing');
+ }
queryExecutor.updateDraft('thread_a', 'draft a');
queryExecutor.updateDraft('thread_b', 'draft b');
});
diff --git a/web/database/queries/keyservers-queries.test.js b/web/database/queries/keyservers-queries.test.js
--- a/web/database/queries/keyservers-queries.test.js
+++ b/web/database/queries/keyservers-queries.test.js
@@ -56,9 +56,12 @@
beforeEach(() => {
if (!dbModule) {
- return;
+ throw new Error('Database module is missing');
}
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLiteQueryExecutor is missing');
+ }
queryExecutor?.replaceKeyserver(
convertKeyserverInfoToClientDBKeyserverInfo({
keyserverInfo: TEST_KEYSERVER_1,
diff --git a/web/database/queries/message-store-threads-queries.test.js b/web/database/queries/message-store-threads-queries.test.js
--- a/web/database/queries/message-store-threads-queries.test.js
+++ b/web/database/queries/message-store-threads-queries.test.js
@@ -14,7 +14,13 @@
});
beforeEach(() => {
+ if (!dbModule) {
+ throw new Error('Database module is missing');
+ }
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLiteQueryExecutor is missing');
+ }
queryExecutor.replaceMessageStoreThreads([
{ id: '1', startReached: 0 },
{ id: '2', startReached: 0 },
diff --git a/web/database/queries/message-to-device-queries.test.js b/web/database/queries/message-to-device-queries.test.js
--- a/web/database/queries/message-to-device-queries.test.js
+++ b/web/database/queries/message-to-device-queries.test.js
@@ -65,9 +65,12 @@
beforeEach(() => {
if (!dbModule) {
- return;
+ throw new Error('Database module is missing');
}
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLiteQueryExecutor is missing');
+ }
queryExecutor?.addMessagesToDevice([
TEST_MSG_1,
TEST_MSG_2,
diff --git a/web/database/queries/messages-and-media-queries.test.js b/web/database/queries/messages-and-media-queries.test.js
--- a/web/database/queries/messages-and-media-queries.test.js
+++ b/web/database/queries/messages-and-media-queries.test.js
@@ -14,7 +14,13 @@
});
beforeEach(() => {
+ if (!dbModule) {
+ throw new Error('Database module is missing');
+ }
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLiteQueryExecutor is missing');
+ }
queryExecutor.replaceMessageWeb({
id: '1',
localID: { value: '', isNull: true },
@@ -84,7 +90,7 @@
});
it('should return all messages with media', () => {
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor?.getAllMessagesWeb();
expect(allMessages.length).toBe(3);
expect(allMessages[0].medias.length).toBe(2);
expect(allMessages[1].medias.length).toBe(0);
@@ -92,8 +98,8 @@
});
it('should remove all messages', () => {
- queryExecutor.removeAllMessages();
- const allMessages = queryExecutor.getAllMessagesWeb();
+ queryExecutor?.removeAllMessages();
+ const allMessages = queryExecutor?.getAllMessagesWeb();
expect(allMessages.length).toBe(0);
});
@@ -106,52 +112,52 @@
});
it('should remove all messages for threads', () => {
- queryExecutor.removeMessagesForThreads(['1']);
- const allMessages = queryExecutor.getAllMessagesWeb();
+ queryExecutor?.removeMessagesForThreads(['1']);
+ const allMessages = queryExecutor?.getAllMessagesWeb();
expect(allMessages.length).toBe(1);
});
it('should remove all messages with ids', () => {
- queryExecutor.removeMessages(['1']);
- const allMessages = queryExecutor.getAllMessagesWeb();
+ queryExecutor?.removeMessages(['1']);
+ const allMessages = queryExecutor?.getAllMessagesWeb();
expect(allMessages.length).toBe(2);
});
it('should remove all media for message', () => {
- queryExecutor.removeMediaForMessage('1');
- const allMessages = queryExecutor.getAllMessagesWeb();
+ queryExecutor?.removeMediaForMessage('1');
+ const allMessages = queryExecutor?.getAllMessagesWeb();
expect(allMessages[0].medias.length).toBe(0);
expect(allMessages[1].medias.length).toBe(0);
expect(allMessages[2].medias.length).toBe(2);
});
it('should remove all media for messages', () => {
- queryExecutor.removeMediaForMessages(['3']);
- const allMessages = queryExecutor.getAllMessagesWeb();
+ queryExecutor?.removeMediaForMessages(['3']);
+ const allMessages = queryExecutor?.getAllMessagesWeb();
expect(allMessages[0].medias.length).toBe(2);
expect(allMessages[1].medias.length).toBe(0);
expect(allMessages[2].medias.length).toBe(0);
});
it('should remove all media for threads', () => {
- queryExecutor.removeMediaForThreads(['2']);
- const allMessages = queryExecutor.getAllMessagesWeb();
+ queryExecutor?.removeMediaForThreads(['2']);
+ const allMessages = queryExecutor?.getAllMessagesWeb();
expect(allMessages[0].medias.length).toBe(2);
expect(allMessages[1].medias.length).toBe(0);
expect(allMessages[2].medias.length).toBe(0);
});
it('should rekey media containers', () => {
- queryExecutor.rekeyMediaContainers('1', '3');
- const allMessages = queryExecutor.getAllMessagesWeb();
+ queryExecutor?.rekeyMediaContainers('1', '3');
+ const allMessages = queryExecutor?.getAllMessagesWeb();
expect(allMessages[0].medias.length).toBe(0);
expect(allMessages[1].medias.length).toBe(0);
expect(allMessages[2].medias.length).toBe(4);
});
it('should rekey message', () => {
- queryExecutor.rekeyMessage('3', '2');
- const allMessages = queryExecutor.getAllMessagesWeb();
+ queryExecutor?.rekeyMessage('3', '2');
+ const allMessages = queryExecutor?.getAllMessagesWeb();
expect(allMessages.length).toBe(2);
const rekeyedMessage = allMessages.find(
messageWithMedia => messageWithMedia.message.id === '2',
@@ -160,7 +166,7 @@
});
it('should correctly handle nullable integer', () => {
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor?.getAllMessagesWeb();
const messageWithNullFutureType = allMessages.find(
messageWithMedia => messageWithMedia.message.id === '1',
);
diff --git a/web/database/queries/metadata-queries.test.js b/web/database/queries/metadata-queries.test.js
--- a/web/database/queries/metadata-queries.test.js
+++ b/web/database/queries/metadata-queries.test.js
@@ -17,7 +17,13 @@
});
beforeEach(() => {
+ if (!dbModule) {
+ throw new Error('Database module is missing');
+ }
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLiteQueryExecutor is missing');
+ }
queryExecutor.setMetadata(TEST_USER_ID_KEY, TEST_USER_ID_VAL);
});
diff --git a/web/database/queries/olm-persist-data-queries.test.js b/web/database/queries/olm-persist-data-queries.test.js
--- a/web/database/queries/olm-persist-data-queries.test.js
+++ b/web/database/queries/olm-persist-data-queries.test.js
@@ -14,7 +14,13 @@
});
beforeEach(() => {
+ if (!dbModule) {
+ throw new Error('Database module is missing');
+ }
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLiteQueryExecutor is missing');
+ }
queryExecutor.storeOlmPersistAccount('accountData');
queryExecutor.storeOlmPersistSession({
diff --git a/web/database/queries/report-queries.test.js b/web/database/queries/report-queries.test.js
--- a/web/database/queries/report-queries.test.js
+++ b/web/database/queries/report-queries.test.js
@@ -14,7 +14,13 @@
});
beforeEach(() => {
+ if (!dbModule) {
+ throw new Error('Database module is missing');
+ }
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLiteQueryExecutor is missing');
+ }
queryExecutor.replaceReport({ id: '1', report: '{report_content_1}' });
queryExecutor.replaceReport({ id: '2', report: '{report_content_2}' });
});
diff --git a/web/database/queries/storage-engine-queries.test.js b/web/database/queries/storage-engine-queries.test.js
--- a/web/database/queries/storage-engine-queries.test.js
+++ b/web/database/queries/storage-engine-queries.test.js
@@ -17,7 +17,13 @@
});
beforeEach(() => {
+ if (!dbModule) {
+ throw new Error('Database module is missing');
+ }
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLiteQueryExecutor is missing');
+ }
queryExecutor.setPersistStorageItem(TEST_KEY, TEST_ITEM);
});
diff --git a/web/database/queries/threads-queries.test.js b/web/database/queries/threads-queries.test.js
--- a/web/database/queries/threads-queries.test.js
+++ b/web/database/queries/threads-queries.test.js
@@ -14,7 +14,13 @@
});
beforeEach(() => {
+ if (!dbModule) {
+ throw new Error('Database module is missing');
+ }
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLiteQueryExecutor is missing');
+ }
queryExecutor.replaceThreadWeb({
id: '1',
type: 1,
@@ -76,19 +82,19 @@
});
it('should return all threads', () => {
- const threads = queryExecutor.getAllThreadsWeb();
+ const threads = queryExecutor?.getAllThreadsWeb();
expect(threads.length).toBe(3);
});
it('should remove all threads', () => {
- queryExecutor.removeAllThreads();
- const threads = queryExecutor.getAllThreadsWeb();
+ queryExecutor?.removeAllThreads();
+ const threads = queryExecutor?.getAllThreadsWeb();
expect(threads.length).toBe(0);
});
it('should remove subset of threads', () => {
- queryExecutor.removeThreads(['2']);
- const threads = queryExecutor.getAllThreadsWeb();
+ queryExecutor?.removeThreads(['2']);
+ const threads = queryExecutor?.getAllThreadsWeb();
expect(threads.length).toBe(2);
});
});
diff --git a/web/database/queries/user-quries.test.js b/web/database/queries/user-quries.test.js
--- a/web/database/queries/user-quries.test.js
+++ b/web/database/queries/user-quries.test.js
@@ -42,9 +42,12 @@
beforeEach(() => {
if (!dbModule) {
- return;
+ throw new Error('Database module is missing');
}
queryExecutor = new dbModule.SQLiteQueryExecutor(FILE_PATH);
+ if (!queryExecutor) {
+ throw new Error('SQLiteQueryExecutor is missing');
+ }
queryExecutor?.replaceUser(convertUserInfoToClientDBUserInfo(TEST_USER_1));
queryExecutor?.replaceUser(convertUserInfoToClientDBUserInfo(TEST_USER_2));
});

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 7:13 PM (8 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700869
Default Alt Text
D11241.id37809.diff (11 KB)

Event Timeline