Skip to content

Commit

Permalink
use npm to test via node
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatz-drizly committed Oct 25, 2018
1 parent 3840d5d commit 1429886
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ services:

before_install:
- docker build -t eficode/wait-for .

script:
- npm install
- ./run_tests.sh
- docker run eficode/wait-for
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ WORKDIR /app
COPY . /app
RUN npm install

CMD ./node_modules/.bin/bats wait-for.bats
# On launch, run the test suite via npm
CMD npm test
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "wait-for",
"version": "0.1.0",
"scripts": {
"test": "./node_modules/.bin/bats wait-for.bats"
"test": "./run_tests.sh"
},
"dependencies": {
"bats": "^0.4.2"
Expand Down
8 changes: 8 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# Although it would be possible to just call this directly from the Dockerfile,
# centralizing tests in this file allows both the docker container and the
# CI machine to run the same set of tests for an additional datapoint --
# which gives a better chance of turning up POSIX noncompliance

./node_modules/.bin/bats wait-for.bats
4 changes: 2 additions & 2 deletions wait-for
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

OLD_TIMEOUT=$TIMEOUT
OLD_QUIET=$QUIET
Expand Down Expand Up @@ -34,7 +34,7 @@ USAGE

test_connection() {
# force a 1-second timeout on darwin (https://stackoverflow.com/a/20460402/2063546)
if [ -z "${$OSTYPE##*darwin*}" ] ; then
if [ -z "${OSTYPE##*darwin*}" ] ; then
nc -w 1 -G 1 "$1" "$2" > /dev/null 2>&1
else
nc -w 1 "$1" "$2" > /dev/null 2>&1
Expand Down

0 comments on commit 1429886

Please sign in to comment.