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:
parent
d3b9bcb7be
commit
436f295dc5
@ -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',
|
@ -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);
|
|
||||||
},
|
|
||||||
};
|
|
8
src/test/e2e/helpers/database-config.ts
Normal file
8
src/test/e2e/helpers/database-config.ts
Normal 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);
|
||||||
|
};
|
@ -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,
|
||||||
|
@ -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;
|
Loading…
Reference in New Issue
Block a user