-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for running as included module
This adds a separate test for checking that the server can start up when included as a module. The needed package.json and the test itself are copied into a temporary directory, then the server install is npm pack'd and installed into the temp directory. Everything I tried within the server directory ended up with npm complaining or shortcutting things so that the test either did not work or tested nothing.
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "empty", | ||
"version": "1.0.0", | ||
"main": "works-as-include.js", | ||
"dependencies": { | ||
"app-root-path": "^2.1.0" | ||
} | ||
} |
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,24 @@ | ||
#!/bin/bash | ||
|
||
TMPDIR=$(mktemp -d) | ||
|
||
trap "exit 1" HUP INT PIPE QUIT TERM | ||
trap "rm -rf $TMPDIR" EXIT | ||
|
||
BASEDIR=$(dirname $0) | ||
|
||
#copy test files to the tmp directory | ||
cp -r ${BASEDIR} $TMPDIR | ||
|
||
#pack the server and install from the packed tar file | ||
ORIGINDIR=$(PWD) | ||
PACKEDTARFILE=$(npm pack 2>/dev/null) | ||
cd $TMPDIR/$BASEDIR | ||
npm install | ||
npm install $ORIGINDIR/$PACKEDTARFILE | ||
|
||
export SETTINGSDIR=$TMPDIR/settings | ||
mkdir $SETTINGSDIR | ||
|
||
node works-as-include.js | ||
|
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,12 @@ | ||
const appRoot = require('app-root-path') | ||
const SignalKServer = require('signalk-server') | ||
const path = require('path') | ||
|
||
const config = { | ||
appPath: appRoot.path, | ||
configPath: process.env.SETTINGSDIR | ||
} | ||
|
||
console.log(config) | ||
const server = new SignalKServer({ config }); | ||
server.start() |