1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

fix: convert files to typescript

This commit is contained in:
Ivar Conradi Østhus 2021-09-14 19:30:11 +02:00
parent d3b9bcb7be
commit 436f295dc5
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09
5 changed files with 17 additions and 24 deletions

View File

@ -1,7 +1,5 @@
'use strict'; import express from 'express';
import { createTestConfig } from '../test/config/test-config';
const express = require('express');
const { createTestConfig } = require('../test/config/test-config');
jest.mock( jest.mock(
'./routes', './routes',

View File

@ -1,12 +0,0 @@
'use strict';
const parseDbUrl = require('parse-database-url');
module.exports = {
getDb: () => {
const url =
process.env.TEST_DATABASE_URL ||
'postgres://unleash_user:passord@localhost:5432/unleash_test';
return parseDbUrl(url);
},
};

View File

@ -0,0 +1,8 @@
import parseDbUrl from 'parse-database-url';
export const getDbConfig = (): object => {
const url =
process.env.TEST_DATABASE_URL ||
'postgres://unleash_user:passord@localhost:5432/unleash_test';
return parseDbUrl(url);
};

View File

@ -2,7 +2,7 @@ import { EventEmitter } from 'events';
import { migrateDb } from '../../../migrator'; import { migrateDb } from '../../../migrator';
import { createStores } from '../../../lib/db'; import { createStores } from '../../../lib/db';
import { createDb } from '../../../lib/db/db-pool'; import { createDb } from '../../../lib/db/db-pool';
import dbConfig from './database-config'; import { getDbConfig } from './database-config';
import { createTestConfig } from '../../config/test-config'; import { createTestConfig } from '../../config/test-config';
import dbState from './database.json'; import dbState from './database.json';
import { LogProvider } from '../../../lib/logger'; import { LogProvider } from '../../../lib/logger';
@ -77,12 +77,12 @@ export interface ITestDb {
} }
export default async function init( export default async function init(
databaseSchema: String = 'test', databaseSchema: string = 'test',
getLogger: LogProvider = noLoggerProvider, getLogger: LogProvider = noLoggerProvider,
): Promise<ITestDb> { ): Promise<ITestDb> {
const config = createTestConfig({ const config = createTestConfig({
db: { db: {
...dbConfig.getDb(), ...getDbConfig(),
pool: { min: 2, max: 8 }, pool: { min: 2, max: 8 },
schema: databaseSchema, schema: databaseSchema,
ssl: false, ssl: false,

View File

@ -1,7 +1,4 @@
'use strict'; const adminUser = (): { hook: (app: any) => void } => {
module.exports = () => {
const _perms = ['ADMIN'];
return { return {
hook(app) { hook(app) {
app.use((req, res, next) => { app.use((req, res, next) => {
@ -9,10 +6,12 @@ module.exports = () => {
isAPI: true, isAPI: true,
id: 1, id: 1,
email: 'unknown', email: 'unknown',
permissions: _perms, permissions: ['ADMIN'],
}; };
next(); next();
}); });
}, },
}; };
}; };
export default adminUser;