-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·97 lines (83 loc) · 1.83 KB
/
run_tests.sh
File metadata and controls
executable file
·97 lines (83 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
UNIT=0
INTEGRATION=0
DOCKER=0
STAGE="dev"
function printUsage {
echo "Usage: ./run_tests.sh COMMAND
Run tests
Commands:
unit Run unit tests
integration Run integration tests
docker Run integration tests using docker"
}
function printIntegrationUsage {
echo "Usage: ./run_tests.sh integration [OPTIONS]
Run integration tests
Options:
--stage string The environemnt tests will run against (default 'dev')"
}
case $1 in
unit)
UNIT=1
;;
integration)
INTEGRATION=1
case $2 in
-s | --stage)
if [ -n "$3" ]; then
STAGE=$3
else
echo "a stage needs to be provided"
printIntegrationUsage
exit
fi
;;
-h | --help )
printIntegrationUsage
exit
;;
*)
echo "unknown flag $2"
printIntegrationUsage
exit 1
esac
;;
docker)
DOCKER=1
;;
-h | --help )
printUsage
exit
;;
*)
echo "command $1 is not recognized as a valid command"
printUsage
exit 1
esac
function runIntegrationTests {
npm install
node_modules/.bin/sls deploy --stage $STAGE
node_modules/.bin/mocha tests/integration.test.js --stage $STAGE
node_modules/.bin/sls remove --stage $STAGE
}
function runDockerTests {
./build.sh rebuild
node_modules/.bin/mocha tests/integration.test.js --stage dkr --endpoint http://localhost:3001
}
function runUnitTests {
npm install
node_modules/.bin/mocha tests/unit.test.js
}
if [ $INTEGRATION -eq 1 ]; then
echo "running integration tests on stage $STAGE..."
runIntegrationTests
fi
if [ $UNIT -eq 1 ]; then
echo "running unit tests..."
runUnitTests
fi
if [ $DOCKER -eq 1 ]; then
echo "running integration tests against docker..."
runDockerTests
fi