mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-12 23:35:50 +00:00
fix tests
This commit is contained in:
parent
10008fa682
commit
0fc425223b
@ -4,7 +4,7 @@
|
||||
"access":
|
||||
{
|
||||
"type": "dateFile",
|
||||
"filename": "../logs/federation/access-%p.log",
|
||||
"filename": "../logs/dht/access-%p.log",
|
||||
"pattern": "yyyy-MM-dd",
|
||||
"layout":
|
||||
{
|
||||
@ -17,7 +17,7 @@
|
||||
"apollo":
|
||||
{
|
||||
"type": "dateFile",
|
||||
"filename": "../logs/federation/apollo-%p.log",
|
||||
"filename": "../logs/dht/apollo-%p.log",
|
||||
"pattern": "yyyy-MM-dd",
|
||||
"layout":
|
||||
{
|
||||
@ -27,23 +27,10 @@
|
||||
"fileNameSep" : "_",
|
||||
"numBackups" : 30
|
||||
},
|
||||
"backend":
|
||||
"dht":
|
||||
{
|
||||
"type": "dateFile",
|
||||
"filename": "../logs/federation/backend-%p.log",
|
||||
"pattern": "yyyy-MM-dd",
|
||||
"layout":
|
||||
{
|
||||
"type": "pattern", "pattern": "%d{ISO8601} %p %c [%X{user}] [%f : %l] - %m"
|
||||
},
|
||||
"keepFileExt" : true,
|
||||
"fileNameSep" : "_",
|
||||
"numBackups" : 30
|
||||
},
|
||||
"federation":
|
||||
{
|
||||
"type": "dateFile",
|
||||
"filename": "../logs/federation/apiversion-%v-%p.log",
|
||||
"filename": "../logs/dht/apiversion-%v-%p.log",
|
||||
"pattern": "yyyy-MM-dd",
|
||||
"layout":
|
||||
{
|
||||
@ -56,7 +43,7 @@
|
||||
"errorFile":
|
||||
{
|
||||
"type": "dateFile",
|
||||
"filename": "../logs/federation/errors-%p.log",
|
||||
"filename": "../logs/dht/errors-%p.log",
|
||||
"pattern": "yyyy-MM-dd",
|
||||
"layout":
|
||||
{
|
||||
@ -112,22 +99,11 @@
|
||||
"level": "debug",
|
||||
"enableCallStack": true
|
||||
},
|
||||
"backend":
|
||||
"dht":
|
||||
{
|
||||
"appenders":
|
||||
[
|
||||
"backend",
|
||||
"out",
|
||||
"errors"
|
||||
],
|
||||
"level": "debug",
|
||||
"enableCallStack": true
|
||||
},
|
||||
"federation":
|
||||
{
|
||||
"appenders":
|
||||
[
|
||||
"federation",
|
||||
"dht",
|
||||
"out",
|
||||
"errors"
|
||||
],
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/lodash.clonedeep": "^4.5.7",
|
||||
"@types/node": "^18.11.18",
|
||||
"apollo-server-testing": "^2.25.2",
|
||||
"eslint": "^8.31.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-config-standard": "^17.0.0",
|
||||
|
||||
@ -181,7 +181,7 @@ describe('federation', () => {
|
||||
it('logs an error of unexpected data format and structure', () => {
|
||||
expect(logger.error).toBeCalledWith(
|
||||
'Error on receiving data from socket:',
|
||||
new SyntaxError('Unexpected token o in JSON at position 1'),
|
||||
new SyntaxError('Unexpected token \'o\', "no-json string" is not valid JSON'),
|
||||
)
|
||||
})
|
||||
})
|
||||
@ -200,7 +200,7 @@ describe('federation', () => {
|
||||
it('logs an error of unexpected data format and structure', () => {
|
||||
expect(logger.error).toBeCalledWith(
|
||||
'Error on receiving data from socket:',
|
||||
new SyntaxError('Unexpected token i in JSON at position 0'),
|
||||
new SyntaxError('Unexpected token \'i\', "invalid ty"... is not valid JSON'),
|
||||
)
|
||||
})
|
||||
})
|
||||
@ -224,7 +224,7 @@ describe('federation', () => {
|
||||
it('logs an error of unexpected data format and structure', () => {
|
||||
expect(logger.error).toBeCalledWith(
|
||||
'Error on receiving data from socket:',
|
||||
new SyntaxError('Unexpected token a in JSON at position 0'),
|
||||
new SyntaxError('Unexpected token \'a\', "api,url,in"... is not valid JSON'),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import DHT from '@hyperswarm/dht'
|
||||
import { federationLogger as logger } from '@/server/logger'
|
||||
import { logger } from '@/server/logger'
|
||||
import CONFIG from '@/config'
|
||||
import { Community as DbCommunity } from '@entity/Community'
|
||||
|
||||
@ -155,7 +155,7 @@ export const startDHT = async (topic: string): Promise<void> => {
|
||||
})
|
||||
}
|
||||
|
||||
if(collectedPubKeys.length){
|
||||
if (collectedPubKeys.length) {
|
||||
logger.info(`Found new peers: ${collectedPubKeys}`)
|
||||
}
|
||||
|
||||
|
||||
@ -5,31 +5,24 @@ import { readFileSync } from 'fs'
|
||||
|
||||
const options = JSON.parse(readFileSync(CONFIG.LOG4JS_CONFIG, 'utf-8'))
|
||||
|
||||
options.categories.backend.level = CONFIG.LOG_LEVEL
|
||||
options.categories.dht.level = CONFIG.LOG_LEVEL
|
||||
options.categories.apollo.level = CONFIG.LOG_LEVEL
|
||||
let filename: string = options.appenders.federation.filename
|
||||
if (CONFIG.FEDERATION_DHT_TOPIC) {
|
||||
options.appenders.federation.filename = filename
|
||||
.replace('apiversion-%v', 'dht-' + CONFIG.FEDERATION_DHT_TOPIC)
|
||||
.replace('%p', CONFIG.PORT.toString())
|
||||
} else {
|
||||
options.appenders.federation.filename = filename.replace('%p', CONFIG.PORT.toString())
|
||||
}
|
||||
let filename: string = options.appenders.dht.filename
|
||||
options.appenders.dht.filename = filename
|
||||
.replace('apiversion-%v', 'dht-' + CONFIG.FEDERATION_DHT_TOPIC)
|
||||
.replace('%p', CONFIG.PORT.toString())
|
||||
filename = options.appenders.access.filename
|
||||
options.appenders.access.filename = filename.replace('%p', CONFIG.PORT.toString())
|
||||
filename = options.appenders.apollo.filename
|
||||
options.appenders.apollo.filename = filename.replace('%p', CONFIG.PORT.toString())
|
||||
filename = options.appenders.backend.filename
|
||||
options.appenders.backend.filename = filename.replace('%p', CONFIG.PORT.toString())
|
||||
filename = options.appenders.errorFile.filename
|
||||
options.appenders.errorFile.filename = filename.replace('%p', CONFIG.PORT.toString())
|
||||
|
||||
log4js.configure(options)
|
||||
|
||||
const apolloLogger = log4js.getLogger('apollo')
|
||||
// const backendLogger = log4js.getLogger('backend')
|
||||
const federationLogger = log4js.getLogger('federation')
|
||||
const logger = log4js.getLogger('dht')
|
||||
|
||||
// backendLogger.addContext('user', 'unknown')
|
||||
|
||||
export { apolloLogger, federationLogger }
|
||||
export { apolloLogger, logger }
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Migration } from '@entity/Migration'
|
||||
import { federationLogger as logger } from '@/server/logger'
|
||||
import { logger } from '@/server/logger'
|
||||
|
||||
const getDBVersion = async (): Promise<string | null> => {
|
||||
try {
|
||||
|
||||
@ -5,7 +5,7 @@ import { createTestClient } from 'apollo-server-testing'
|
||||
import createServer from '../src/server/createServer'
|
||||
import { initialize } from '@dbTools/helpers'
|
||||
import { entities } from '@entity/index'
|
||||
import { i18n, logger } from './testSetup'
|
||||
import { logger } from './testSetup'
|
||||
|
||||
export const headerPushMock = jest.fn((t) => {
|
||||
context.token = t.value
|
||||
@ -27,8 +27,8 @@ export const cleanDB = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
export const testEnvironment = async (testLogger: any = logger, testI18n: any = i18n) => {
|
||||
const server = await createServer(context, testLogger, testI18n)
|
||||
export const testEnvironment = async (testLogger: any = logger) => {
|
||||
const server = await createServer(testLogger)
|
||||
const con = server.con
|
||||
const testClient = createTestClient(server.apollo)
|
||||
const mutate = testClient.mutate
|
||||
|
||||
@ -1,9 +1,4 @@
|
||||
import CONFIG from '@/config'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
import { i18n } from '@/server/localization'
|
||||
|
||||
CONFIG.EMAIL = true
|
||||
CONFIG.EMAIL_TEST_MODUS = false
|
||||
import { logger } from '@/server/logger'
|
||||
|
||||
jest.setTimeout(1000000)
|
||||
|
||||
@ -12,7 +7,7 @@ jest.mock('@/server/logger', () => {
|
||||
return {
|
||||
__esModule: true,
|
||||
...originalModule,
|
||||
backendLogger: {
|
||||
logger: {
|
||||
addContext: jest.fn(),
|
||||
trace: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
@ -24,18 +19,4 @@ jest.mock('@/server/logger', () => {
|
||||
}
|
||||
})
|
||||
|
||||
jest.mock('@/server/localization', () => {
|
||||
const originalModule = jest.requireActual('@/server/localization')
|
||||
return {
|
||||
__esModule: true,
|
||||
...originalModule,
|
||||
i18n: {
|
||||
init: jest.fn(),
|
||||
// configure: jest.fn(),
|
||||
// __: jest.fn(),
|
||||
// setLocale: jest.fn(),
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
export { logger, i18n }
|
||||
export { logger }
|
||||
|
||||
@ -52,14 +52,14 @@
|
||||
// "@enum/*": ["src/graphql/enum/*"],
|
||||
// "@model/*": ["src/graphql/model/*"],
|
||||
"@repository/*": ["src/typeorm/repository/*"],
|
||||
// "@test/*": ["test/*"],
|
||||
"@test/*": ["test/*"],
|
||||
/* external */
|
||||
"@typeorm/*": ["../backend/src/typeorm/*", "../../backend/src/typeorm/*"],
|
||||
"@dbTools/*": ["../database/src/*", "../../database/build/src/*"],
|
||||
"@entity/*": ["../database/entity/*", "../../database/build/entity/*"]
|
||||
},
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
"typeRoots": ["src/dht_node/@types", "node_modules/@types"], /* List of folders to include type definitions from. */
|
||||
"typeRoots": ["src/dht-node/@types", "node_modules/@types"], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
|
||||
@ -1312,7 +1312,7 @@ apollo-server-caching@^0.7.0:
|
||||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
apollo-server-core@^2.25.2:
|
||||
apollo-server-core@^2.25.2, apollo-server-core@^2.25.3:
|
||||
version "2.26.1"
|
||||
resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-2.26.1.tgz#40a122b42f3ee2ddbfd1bd0c5775cd14eb454688"
|
||||
integrity sha512-YnO1YXhHOnCY7Q2SZ0uUtPq6SLCw+t2uI19l59mzWuCyZYdHrtSy3zUEU6pM3tR9vvUuRGkYIfMRlo/Q8a1U5g==
|
||||
@ -1386,6 +1386,13 @@ apollo-server-plugin-base@^0.14.0:
|
||||
dependencies:
|
||||
apollo-server-types "^0.10.0"
|
||||
|
||||
apollo-server-testing@^2.25.2:
|
||||
version "2.25.3"
|
||||
resolved "https://registry.yarnpkg.com/apollo-server-testing/-/apollo-server-testing-2.25.3.tgz#abf645d73d4fc3a578f547e2e97f45fe8fb1b764"
|
||||
integrity sha512-EELtuDk1dn//fNxeYELuwwAy8bvhV9d60WhZfs3JrXqpzRDZhJmyyGqlMoHmkvCqK/mCOkc4hL54tM9rrFhU5Q==
|
||||
dependencies:
|
||||
apollo-server-core "^2.25.3"
|
||||
|
||||
apollo-server-types@^0.10.0:
|
||||
version "0.10.0"
|
||||
resolved "https://registry.yarnpkg.com/apollo-server-types/-/apollo-server-types-0.10.0.tgz#af578bf507151a0e86fbdf188f9673ece3f8f164"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user