Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit 99b151b

Browse files
dsellarsnrcstryker
authored andcommitted
Setup and README for local testing
1 parent 6a83459 commit 99b151b

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ disabled.
77

88
## Development Setup with docker-compose
99

10-
## Development Setup
11-
1210
### Prerequisites
1311

1412
1. Mac or Linux computer using zsh or bash.
@@ -52,7 +50,7 @@ api-server locally via your IDE or command line.
5250
behavior is to initialize the database and disable outbound
5351
email queueing.
5452
```
55-
./start-api-server.sh [-init-db-only | -no-db | -enable-mailout ]
53+
./start-api-server.sh [-init-db-only | -no-db | -enable-mailout | -mock-mode ]
5654
```
5755

5856
### Method 2 - launch from IDE
@@ -72,3 +70,24 @@ Develop to your heart's content!!!! We _love_ pull-requests.
7270
## Run everything in docker
7371

7472
Not working right now :(. Check back later.
73+
74+
## Running Tests
75+
76+
As usual, make sure you are authenticated with vault.
77+
78+
Start the api server - use `-mock-mode` flag if needed
79+
```bash
80+
./start-api-server.sh [-init-db-only | -no-db | -enable-mailout | -mock-mode ]
81+
```
82+
83+
In a separate terminal, source testMode.sh (this will also set CS_API_MOCK_MODE=1)
84+
85+
```bash
86+
. ./testMode.sh
87+
```
88+
89+
then run the tests
90+
```bash
91+
cd api_server
92+
npm run test
93+
```

api_server/bin/cs_dev_secrets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { readVaultDevSecrets } = require('../../shared/server_utils/dev_secrets')
66
async function main() {
77
const env = await readVaultDevSecrets();
88
for (const key in env) {
9-
console.log(`export ${key}="${shellescape([env[key]])}"`);
9+
console.log(`export ${key}=${shellescape([env[key]])}`);
1010
}
1111
}
1212

start-api-server.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ CSSVC_ENV=$CSSVC_ENV
3131
AWS access will use codestream-server/base/ keys from vault
3232
"
3333

34+
echo "$*" | grep -q '\-mock-mode' && {
35+
echo "======= Mocky ======="
36+
export CS_API_MOCK_MODE=1
37+
}
38+
3439
echo "$*" | grep -q '\-no-db' || {
3540
echo "======= Initializing database ======="
3641
init_database

testMode.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
function dev_settings {
4+
for configVar in `cat $SCRIPT_DIR/api_server/config/local.json|grep '"'|cut -f2 -d\"`; do
5+
value=$(grep "\"$configVar\":" $SCRIPT_DIR/api_server/config/local.json|grep '"'|cut -f4 -d\")
6+
echo "export $configVar='$value'"
7+
done
8+
}
9+
10+
function dev_secrets {
11+
$SCRIPT_DIR/api_server/bin/cs_dev_secrets.js
12+
}
13+
14+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
15+
export CSSVC_BACKEND_ROOT=$SCRIPT_DIR
16+
export NODE_PATH="$CSSVC_BACKEND_ROOT/api_server/node_modules:$CSSVC_BACKEND_ROOT/broadcaster/node_modules"
17+
eval `dev_settings` # Needed for dev_secrets to work
18+
# dev_settings
19+
eval `dev_secrets`
20+
export CS_API_MOCK_MODE='1'
21+
export CSSVC_ENV=local
22+
export CSSVC_CFG_FILE="$CSSVC_BACKEND_ROOT/codestream-docker.json"

0 commit comments

Comments
 (0)