Skip to content

Commit

Permalink
[server] enhanced mocha setups
Browse files Browse the repository at this point in the history
  • Loading branch information
svenefftinge committed Aug 2, 2023
1 parent c5059f2 commit e7cbbac
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 54 deletions.
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

0 comments on commit e7cbbac

Please sign in to comment.