Skip to content

[server] enhanced mocha setups #18390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ vscode:
- dbaeumer.vscode-eslint
- esbenp.prettier-vscode
- akosyakov.gitpod-monitor
- hbenl.vscode-mocha-test-adapter
7 changes: 5 additions & 2 deletions components/gitpod-db/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class Config {
// defaults to be used only in tests
const dbSetup: DatabaseConfig = {
host: process.env.DB_HOST || "localhost",
port: getEnvVarParsed("DB_PORT", Number.parseInt, "3306"),
port: getEnvVarParsed("DB_PORT", Number.parseInt, "23306"),
username: process.env.DB_USERNAME || "gitpod",
password: process.env.DB_PASSWORD || "test",
database: process.env.DB_NAME || "gitpod",
Expand Down Expand Up @@ -50,7 +50,10 @@ export class Config {
}

get dbEncryptionKeys(): string {
return getEnvVar("DB_ENCRYPTION_KEYS");
return getEnvVar(
"DB_ENCRYPTION_KEYS",
`[{"name":"general","version":1,"primary":true,"material":"5vRrp0H4oRgdkPnX1qQcS54Q0xggr6iyho42IQ1rO+c="}]`,
);
}
}

Expand Down
46 changes: 0 additions & 46 deletions components/server/.vscode/launch.json

This file was deleted.

16 changes: 16 additions & 0 deletions components/server/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"mochaExplorer.files": [
"dist/**/*.spec.js",
"dist/**/*.spec.db.js"
],
"mochaExplorer.require": [
"source-map-support/register",
"reflect-metadata/Reflect"
],
"mochaExplorer.watch": [
"dist/**/*.spec.js",
"dist/**/*.spec.db.js"
],
"mochaExplorer.exit": true,
"mochaExplorer.timeout": 60000
}
5 changes: 4 additions & 1 deletion components/server/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ packages:
type: yarn
srcs:
- "src/**"
- "typings/**"
- "test/**"
- .eslintrc
- package.json
Expand All @@ -24,6 +23,10 @@ packages:
packaging: offline-mirror
yarnLock: ${coreYarnLockBase}/yarn.lock
tsconfig: tsconfig.json
commands:
# leeway executes the build and test step in the wrong order, so we have to switch them here
test: ["yarn", "build"]
build: ["yarn", "test"]
- name: docker
type: docker
deps:
Expand Down
5 changes: 2 additions & 3 deletions components/server/mocha.opts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
--require ts-node/register
--require reflect-metadata/Reflect
--require source-map-support/register
--reporter spec
--watch-extensions ts
--exit
--watch-extensions js
--exit
4 changes: 2 additions & 2 deletions components/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"clean:node": "rimraf node_modules",
"purge": "yarn clean && yarn clean:node && yarn run rimraf yarn.lock",
"test": "cleanup() { echo 'Cleanup started'; yarn stop-services; }; trap cleanup EXIT; yarn test:unit && yarn start-services && yarn test:db",
"test:unit": "TS_NODE_FILES=true mocha --opts mocha.opts './**/*.spec.ts' --exclude './node_modules/**'",
"test:db": ". $(leeway run components/gitpod-db:db-test-env) && TS_NODE_FILES=true mocha --opts mocha.opts './**/*.spec.db.ts' --exclude './node_modules/**'",
"test:unit": "mocha --opts mocha.opts './**/*.spec.js' --exclude './node_modules/**'",
"test:db": ". $(leeway run components/gitpod-db:db-test-env) && mocha --opts mocha.opts './**/*.spec.db.js' --exclude './node_modules/**'",
"start-services": "yarn start-testdb && yarn start-redis && yarn start-spicedb",
"stop-services": "yarn stop-redis && yarn stop-spicedb",
"start-testdb": "if netstat -tuln | grep ':23306 '; then echo 'Mysql is already running.'; else leeway run components/gitpod-db:init-testdb; fi",
Expand Down