Skip to content

Commit

Permalink
Improved tests, add base for local testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Jan 16, 2025
1 parent ce44e0a commit e2604be
Show file tree
Hide file tree
Showing 8 changed files with 362 additions and 291 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ jobs:
- name: Build
run: npm run build

- name: Run Tests
- name: Run Tests (local)
run: |
export TEST_DEPLOY_LOCAL="true"
npm install -g @metacall/faas
metacall-faas &
sleep 10
npm run coverage
- name: Run Tests (production)
if: github.event_name != 'pull_request'
run: |
touch .env
echo 'METACALL_AUTH_EMAIL="${{ secrets.METACALL_AUTH_EMAIL }}"' >> .env
Expand Down
37 changes: 37 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Run mocha (local)",
"runtimeExecutable": "mocha",
"cwd": "${workspaceFolder}",
"args": ["dist/test"],
"preLaunchTask": "npm: buildDebug",
"autoAttachChildProcesses": true,
"env": {
"TEST_DEPLOY_LOCAL": "true"
}
},
{
"type": "node",
"request": "launch",
"name": "Run mocha (production)",
"runtimeExecutable": "mocha",
"cwd": "${workspaceFolder}",
"args": ["dist/test"],
"preLaunchTask": "npm: buildDebug",
"autoAttachChildProcesses": true
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/dist/index.js",
"preLaunchTask": "npm: buildDebug",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"metacall-deploy": "dist/index.js"
},
"scripts": {
"test": "npm run --silent build && mocha dist/test",
"test": "npm run buildDebug && mocha dist/test",
"coverage": "nyc npm run test",
"unit-integration": "npm run --silent test -- --ignore **/*.integration.spec.js",
"unit": "npm run --silent test -- --ignore **/*.integration.spec.js",
"prepublishOnly": "npm run --silent build",
"postinstall": "node -e \"require('fs').existsSync('githooks') && require('./githooks/configure.js').configure()\"",
"build": "npm run --silent lint && tsc",
"buildDebug": "npm run --silent lint && tsc --sourceMap true",
"lint": "eslint . --ignore-pattern dist",
"fix": "eslint . --ignore-pattern dist --fix",
"start": "node dist/index.js"
Expand All @@ -27,9 +28,9 @@
"deploy",
"tool"
],
"author": "Thomas Rory Gummerson <[email protected]> (https://trgwii.no/)",
"author": "Vicente Eduardo Ferrer Garcia <[email protected]> (https://metacall.io/)",
"contributors": [
"Vicente Eduardo Ferrer Garcia <[email protected]> (https://metacall.io/)"
"Thomas Rory Gummerson <[email protected]> (https://trgwii.no/)"
],
"license": "Apache-2.0",
"bugs": {
Expand Down
4 changes: 3 additions & 1 deletion src/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import { auth } from './auth';
import args from './cli/args';
import { Config, defaultPath, load } from './config';

const devToken = 'local'; // Use some random token in order to proceed

export const startup = async (confDir: string | undefined): Promise<Config> => {
const config = await load(confDir || defaultPath);
const token = args['dev'] ? '' : await auth(config);
const token = args['dev'] ? devToken : await auth(config);

return Object.assign(config, { token });
};
Loading

0 comments on commit e2604be

Please sign in to comment.