forked from shellhub-io/shellhub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-unit
executable file
·59 lines (46 loc) · 1 KB
/
test-unit
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
#!/bin/bash
usage() {
cat <<EOF
Usage: $0 PROJECT [ARG...]
Run unit tests of a project under development machine.
Projects:
* api
* ssh
* agent
* ui
Use comma separated for multiple projects, e.g. 'api,ui'
EOF
exit 1
}
go_test() {
local container
container=$1
echo "Running unit tests on $container"
docker-compose \
-f docker-compose.yml -f docker-compose.dev.yml \
exec $container go test -v ${@:2} ./...
}
npm_test() {
local container
container=$1
echo "Running unit tests on $container"
docker-compose \
-f docker-compose.yml -f docker-compose.dev.yml \
exec $container npm run test:unit ${@:2}
}
[ -z "$1" ] && usage
projects=($(echo $1 | tr "," "\n"))
for project in "${projects[@]}"; do
case "$project" in
"api"|"ssh"|"agent")
go_test $project ${@:2}
;;
"ui")
npm_test $project ${@:2}
;;
*)
echo "Unknown project: $project"
exit 1
;;
esac
done