mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
fix test setup
This commit is contained in:
parent
738b7942c1
commit
f12176c35f
@ -17,18 +17,12 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hyperswarm/dht": "^6.3.3",
|
"@hyperswarm/dht": "^6.3.3",
|
||||||
"apollo-server-express": "2.25.2",
|
|
||||||
"class-validator": "^0.13.2",
|
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"dotenv": "10.0.0",
|
"dotenv": "10.0.0",
|
||||||
"express": "4.17.1",
|
|
||||||
"graphql": "15.5.1",
|
|
||||||
"log4js": "^6.7.1",
|
"log4js": "^6.7.1",
|
||||||
"nodemon": "^2.0.20",
|
"nodemon": "^2.0.20",
|
||||||
"reflect-metadata": "^0.1.13",
|
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"tsconfig-paths": "^4.1.2",
|
"tsconfig-paths": "^4.1.2",
|
||||||
"type-graphql": "^1.1.1",
|
|
||||||
"typescript": "^4.9.4"
|
"typescript": "^4.9.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -36,9 +30,7 @@
|
|||||||
"@typescript-eslint/parser": "^5.48.0",
|
"@typescript-eslint/parser": "^5.48.0",
|
||||||
"@types/dotenv": "^8.2.0",
|
"@types/dotenv": "^8.2.0",
|
||||||
"@types/jest": "^27.0.2",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/lodash.clonedeep": "^4.5.7",
|
|
||||||
"@types/node": "^18.11.18",
|
"@types/node": "^18.11.18",
|
||||||
"apollo-server-testing": "^2.25.2",
|
|
||||||
"eslint": "^8.31.0",
|
"eslint": "^8.31.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-config-standard": "^17.0.0",
|
"eslint-config-standard": "^17.0.0",
|
||||||
|
|||||||
@ -3,8 +3,25 @@ import { startDHT } from '@/dht_node/index'
|
|||||||
|
|
||||||
// config
|
// config
|
||||||
import CONFIG from './config'
|
import CONFIG from './config'
|
||||||
|
import { logger } from './server/logger'
|
||||||
|
import connection from './typeorm/connection'
|
||||||
|
import { checkDBVersion } from './typeorm/DBVersion'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
// open mysql connection
|
||||||
|
const con = await connection()
|
||||||
|
if (!con || !con.isConnected) {
|
||||||
|
logger.fatal(`Couldn't open connection to database!`)
|
||||||
|
throw new Error(`Fatal: Couldn't open connection to database`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for correct database version
|
||||||
|
const dbVersion = await checkDBVersion(CONFIG.DB_VERSION)
|
||||||
|
if (!dbVersion) {
|
||||||
|
logger.fatal('Fatal: Database Version incorrect')
|
||||||
|
throw new Error('Fatal: Database Version incorrect')
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(
|
console.log(
|
||||||
`starting Federation on ${CONFIG.FEDERATION_DHT_TOPIC} ${
|
`starting Federation on ${CONFIG.FEDERATION_DHT_TOPIC} ${
|
||||||
|
|||||||
@ -8,15 +8,13 @@ const options = JSON.parse(readFileSync(CONFIG.LOG4JS_CONFIG, 'utf-8'))
|
|||||||
options.categories.dht.level = CONFIG.LOG_LEVEL
|
options.categories.dht.level = CONFIG.LOG_LEVEL
|
||||||
options.categories.apollo.level = CONFIG.LOG_LEVEL
|
options.categories.apollo.level = CONFIG.LOG_LEVEL
|
||||||
let filename: string = options.appenders.dht.filename
|
let filename: string = options.appenders.dht.filename
|
||||||
options.appenders.dht.filename = filename
|
options.appenders.dht.filename = filename.replace(
|
||||||
.replace('apiversion-%v', 'dht-' + CONFIG.FEDERATION_DHT_TOPIC)
|
'apiversion-%v',
|
||||||
.replace('%p', CONFIG.PORT.toString())
|
'dht-' + CONFIG.FEDERATION_DHT_TOPIC,
|
||||||
|
)
|
||||||
filename = options.appenders.access.filename
|
filename = options.appenders.access.filename
|
||||||
options.appenders.access.filename = filename.replace('%p', CONFIG.PORT.toString())
|
|
||||||
filename = options.appenders.apollo.filename
|
filename = options.appenders.apollo.filename
|
||||||
options.appenders.apollo.filename = filename.replace('%p', CONFIG.PORT.toString())
|
|
||||||
filename = options.appenders.errorFile.filename
|
filename = options.appenders.errorFile.filename
|
||||||
options.appenders.errorFile.filename = filename.replace('%p', CONFIG.PORT.toString())
|
|
||||||
|
|
||||||
log4js.configure(options)
|
log4js.configure(options)
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import CONFIG from '@/config'
|
||||||
import createServer from '../src/server/createServer'
|
import connection from '@/typeorm/connection'
|
||||||
|
import { checkDBVersion } from '@/typeorm/DBVersion'
|
||||||
import { initialize } from '@dbTools/helpers'
|
import { initialize } from '@dbTools/helpers'
|
||||||
import { entities } from '@entity/index'
|
import { entities } from '@entity/index'
|
||||||
import { logger } from './testSetup'
|
import { logger } from './testSetup'
|
||||||
@ -28,13 +29,21 @@ export const cleanDB = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const testEnvironment = async (testLogger: any = logger) => {
|
export const testEnvironment = async (testLogger: any = logger) => {
|
||||||
const server = await createServer(testLogger)
|
// open mysql connection
|
||||||
const con = server.con
|
const con = await connection()
|
||||||
const testClient = createTestClient(server.apollo)
|
if (!con || !con.isConnected) {
|
||||||
const mutate = testClient.mutate
|
logger.fatal(`Couldn't open connection to database!`)
|
||||||
const query = testClient.query
|
throw new Error(`Fatal: Couldn't open connection to database`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for correct database version
|
||||||
|
const dbVersion = await checkDBVersion(CONFIG.DB_VERSION)
|
||||||
|
if (!dbVersion) {
|
||||||
|
logger.fatal('Fatal: Database Version incorrect')
|
||||||
|
throw new Error('Fatal: Database Version incorrect')
|
||||||
|
}
|
||||||
await initialize()
|
await initialize()
|
||||||
return { mutate, query, con }
|
return { con }
|
||||||
}
|
}
|
||||||
|
|
||||||
export const resetEntity = async (entity: any) => {
|
export const resetEntity = async (entity: any) => {
|
||||||
|
|||||||
1331
dht-node/yarn.lock
1331
dht-node/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user