-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Tests improvements * Fixes in jest config * Fix tests * Change test db cleanup method * Remove comment * Return dist/run folder
- Loading branch information
1 parent
d28d25a
commit 8be88eb
Showing
37 changed files
with
220 additions
and
479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export { | ||
decodeId, | ||
waitDatabase, | ||
setCiEnv, | ||
dlContext, | ||
finalRequestHandler, | ||
logError, | ||
checkReadOnlyMode, | ||
resolveWorkbookId, | ||
setCiEnv, | ||
} from '../src/components/middlewares'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export {testTenantId} from '../src/tests/int/constants'; | ||
export {testDbConfig, getTestDsnList} from '../src/tests/int/db'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const DSNParser = require('dsn-parser'); | ||
const knexBuilder = require('knex'); | ||
const _ = require('lodash'); | ||
|
||
const {getKnexOptions} = require('../../dist/server/db/init-db'); | ||
const {getTestDsnList} = require('../../dist/server/tests/int/db'); | ||
|
||
const prepareTestUsDb = async ({dsnList}) => { | ||
const knexOptions = _.merge({}, getKnexOptions(), { | ||
connection: dsnList, | ||
}); | ||
|
||
const knexInstance = knexBuilder(knexOptions); | ||
|
||
await knexInstance.raw(` | ||
DROP SCHEMA public CASCADE; | ||
CREATE SCHEMA public; | ||
`); | ||
|
||
await knexInstance.raw(` | ||
CREATE EXTENSION IF NOT EXISTS pg_trgm; | ||
CREATE EXTENSION IF NOT EXISTS btree_gin; | ||
CREATE EXTENSION IF NOT EXISTS btree_gist; | ||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | ||
`); | ||
|
||
await knexInstance.migrate.latest(); | ||
await knexInstance.destroy(); | ||
}; | ||
|
||
const prepareTestDb = async () => { | ||
const dsnList = getTestDsnList(); | ||
|
||
const testDbName = 'int-testing_us_ci_purgeable'; | ||
const parsedDsn = new DSNParser(dsnList); | ||
if (parsedDsn.getParts().database !== testDbName) { | ||
throw new Error(`Database for tests should be named \`${testDbName}\`!`); | ||
} | ||
|
||
await prepareTestUsDb({dsnList}); | ||
}; | ||
|
||
module.exports = {prepareTestDb}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
import {Request, Response, NextFunction} from '@gravity-ui/expresskit'; | ||
import { | ||
testUserId, | ||
testUserLogin, | ||
TEST_USER_ID_HEADER, | ||
TEST_USER_LOGIN_HEADER, | ||
} from '../../tests/int/constants'; | ||
|
||
export const setCiEnv = (req: Request, res: Response, next: NextFunction) => { | ||
res.locals.userId = req.headers[TEST_USER_ID_HEADER] ?? testUserId; | ||
res.locals.login = req.headers[TEST_USER_LOGIN_HEADER] ?? testUserLogin; | ||
res.locals.userId = 'dev-user-id'; | ||
res.locals.login = 'dev-user-login'; | ||
|
||
next(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
import {AuthPolicy} from '@gravity-ui/expresskit'; | ||
import {AppConfig} from '@gravity-ui/nodekit'; | ||
|
||
export default { | ||
appAuthPolicy: AuthPolicy.disabled, | ||
} as Partial<AppConfig>; | ||
export default {} as Partial<AppConfig>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.