From 814bb996dbc0c79875b632c27c2097d03c31a7fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Fri, 16 Dec 2022 01:31:58 +0100 Subject: [PATCH] merge of PR-2465: setup unit tests for federation --- backend/src/config/index.ts | 2 +- backend/src/federation/index.test.ts | 19 +++++++++++++++++++ .../Community.ts | 0 database/entity/Community.ts | 2 +- ...table.ts => 0056-add_communities_table.ts} | 0 5 files changed, 21 insertions(+), 2 deletions(-) rename database/entity/{0055-add_communities_table => 0056-add_communities_table}/Community.ts (100%) rename database/migrations/{0055-add_communities_table.ts => 0056-add_communities_table.ts} (100%) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 780c0b414..3806f01f9 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0055-consistent_deleted_users', + DB_VERSION: '0056-add_communities_table', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info diff --git a/backend/src/federation/index.test.ts b/backend/src/federation/index.test.ts index 4bf4d60a3..7f4dd8fad 100644 --- a/backend/src/federation/index.test.ts +++ b/backend/src/federation/index.test.ts @@ -155,6 +155,25 @@ describe('federation', () => { expect(true).toBe(true) }) }) + describe('on data with receiving simply a string', () => { + beforeEach(() => { + socketEventMocks.data( + Buffer.from( + `hello here is a new community and i don't know how to communicate with you`, + ), + ) + }) + it('logged the received data', () => { + expect(logger.info).toBeCalledWith( + `data: hello here is a new community and i don't know how to communicate with you`, + ) + }) + it('logged a warning of unexpected data format and structure', () => { + expect(logger.warn).toBeCalledWith( + `received totaly wrong or too much apiVersions-Definition JSON-String:hello here is a new community and i don't know how to communicate with you`, + ) + }) + }) }) }) }) diff --git a/database/entity/0055-add_communities_table/Community.ts b/database/entity/0056-add_communities_table/Community.ts similarity index 100% rename from database/entity/0055-add_communities_table/Community.ts rename to database/entity/0056-add_communities_table/Community.ts diff --git a/database/entity/Community.ts b/database/entity/Community.ts index 1ac1fb2f3..0faab133f 100644 --- a/database/entity/Community.ts +++ b/database/entity/Community.ts @@ -1 +1 @@ -export { Community } from './0055-add_communities_table/Community' +export { Community } from './0056-add_communities_table/Community' diff --git a/database/migrations/0055-add_communities_table.ts b/database/migrations/0056-add_communities_table.ts similarity index 100% rename from database/migrations/0055-add_communities_table.ts rename to database/migrations/0056-add_communities_table.ts