Introduce Service Id Types

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
Fedor Indutny 2023-08-10 18:43:33 +02:00 committed by Jamie Kyle
parent 414c0a58d3
commit 366b875fd2
269 changed files with 5832 additions and 5550 deletions

View file

@ -2,20 +2,16 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { v4 as generateUuid } from 'uuid';
import dataInterface from '../../sql/Client';
import { UUID } from '../../types/UUID';
import type { UUIDStringType } from '../../types/UUID';
import { generateAci } from '../../types/ServiceId';
import type { MessageAttributesType } from '../../model-types.d';
const { _getAllMessages, getRecentStoryReplies, removeAll, saveMessages } =
dataInterface;
function getUuid(): UUIDStringType {
return UUID.generate().toString();
}
describe('sql/getRecentStoryReplies', () => {
beforeEach(async () => {
await removeAll();
@ -25,13 +21,13 @@ describe('sql/getRecentStoryReplies', () => {
assert.lengthOf(await _getAllMessages(), 0);
const now = Date.now();
const conversationId1 = getUuid();
const conversationId2 = getUuid();
const conversationId3 = getUuid();
const ourUuid = getUuid();
const storyId = getUuid();
const conversationId1 = generateUuid();
const conversationId2 = generateUuid();
const conversationId3 = generateUuid();
const ourAci = generateAci();
const storyId = generateUuid();
const message1: MessageAttributesType = {
id: getUuid(),
id: generateUuid(),
body: 'message 1 - reply #1',
type: 'incoming',
conversationId: conversationId1,
@ -41,7 +37,7 @@ describe('sql/getRecentStoryReplies', () => {
storyId,
};
const message2: MessageAttributesType = {
id: getUuid(),
id: generateUuid(),
body: 'message 2 - reply #2',
type: 'incoming',
conversationId: conversationId2,
@ -51,7 +47,7 @@ describe('sql/getRecentStoryReplies', () => {
storyId,
};
const message3: MessageAttributesType = {
id: getUuid(),
id: generateUuid(),
body: 'message 3 - reply #3',
type: 'incoming',
conversationId: conversationId3,
@ -61,7 +57,7 @@ describe('sql/getRecentStoryReplies', () => {
storyId,
};
const message4: MessageAttributesType = {
id: getUuid(),
id: generateUuid(),
body: 'message 4 - the story itself',
type: 'story',
conversationId: conversationId3,
@ -71,17 +67,17 @@ describe('sql/getRecentStoryReplies', () => {
storyId,
};
const message5: MessageAttributesType = {
id: getUuid(),
id: generateUuid(),
body: 'message 5 - different story reply',
type: 'incoming',
conversationId: conversationId1,
sent_at: now,
received_at: now,
timestamp: now,
storyId: getUuid(),
storyId: generateUuid(),
};
const message6: MessageAttributesType = {
id: getUuid(),
id: generateUuid(),
body: 'message 6 - no story fields',
type: 'incoming',
conversationId: conversationId1,
@ -94,7 +90,7 @@ describe('sql/getRecentStoryReplies', () => {
[message1, message2, message3, message4, message5, message6],
{
forceSave: true,
ourUuid,
ourAci,
}
);