Skip to content

Commit 1414c50

Browse files
committed
Improved exception checks for docker
1 parent ac7dd20 commit 1414c50

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

docker/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ MAINTAINER Sam Hausmann
44
#install necessary packages
55
RUN apt-get -y update && apt-get install -y git && apt-get install -y vim && apt-get install -y curl
66

7+
RUN npm install -g grunt-cli && npm install -g eslint
8+
79
ENV API_KEY api_key
810

911
RUN mkdir /nodejs-dev

docker/runAll.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
ping_url="https://api.rosette.com/rest/v1/"
44
retcode=0
5+
errors=( "Exception" "processingFailure" "badRequest" "ParseError" "ValueError" "SyntaxError" )
56

67
#------------------- Functions -------------------------------------
78

@@ -15,6 +16,10 @@ function HELP {
1516
exit 1
1617
}
1718

19+
if [ ! -z ${ALT_URL} ]; then
20+
ping_url=${ALT_URL}
21+
fi
22+
1823
#Checks if Rosette API key is valid
1924
function checkAPI() {
2025
match=$(curl "${ping_url}ping" -H "X-RosetteAPI-Key: ${API_KEY}" | grep -o "forbidden")
@@ -54,11 +59,11 @@ function runExample() {
5459
fi
5560
echo "${result}"
5661
echo -e "\n---------- ${1} end -------------"
57-
if [[ $result == *"Exception"* ]]; then
58-
retcode=1
59-
elif [[ $result == *"processingFailure"* ]]; then
60-
retcode=1
61-
fi
62+
for err in "${errors[@]}"; do
63+
if [[ ${result} == *"${err}"* ]]; then
64+
retcode=1
65+
fi
66+
done
6267
}
6368

6469

@@ -87,15 +92,11 @@ validateURL
8792
cp -r -n /source/. .
8893

8994
#Run unit tests
90-
npm install -g grunt-cli
91-
npm install -g eslint
9295
npm install
9396
grunt test
9497
#run eslint
9598
eslint lib/*.js
9699

97-
98-
99100
#Run the examples
100101
if [ ! -z ${API_KEY} ]; then
101102
checkAPI
@@ -104,8 +105,10 @@ if [ ! -z ${API_KEY} ]; then
104105
npm install argparse
105106
npm install temporary
106107
if [ ! -z ${FILENAME} ]; then
108+
echo -e "\nRunning example against: ${ping_url}\n"
107109
runExample ${FILENAME}
108110
else
111+
echo -e "\nRunning examples against: ${ping_url}\n"
109112
for file in *.js; do
110113
runExample $file
111114
done

0 commit comments

Comments
 (0)