-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathtestDB.sh
executable file
·41 lines (37 loc) · 997 Bytes
/
testDB.sh
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
#!/bin/bash
start_test_db() {
docker run --name hex-arch-testing-db -p 5433:5432 -e POSTGRES_USER=test -e POSTGRES_PASSWORD=test -e POSTGRES_DB=template1 -d postgres
}
stop_test_db() {
docker stop hex-arch-testing-db
docker rm hex-arch-testing-db
}
while getopts t: flag; do
case "${flag}" in
t) type=${OPTARG} ;;
esac
done
case $type in
start)
start_test_db
echo "Test database started."
;;
unit)
start_test_db
CGO_ENABLED=0 go test -v -p 1 -count=1 -covermode=count -coverprofile=coverage/c.out -run Unit ./...
stop_test_db
echo "Test database stopped."
;;
integration)
start_test_db
CGO_ENABLED=0 go test -v -p 1 -count=1 -covermode=count -coverprofile=coverage/c.out -run Integration ./...
stop_test_db
echo "Test database stopped."
;;
*)
start_test_db
CGO_ENABLED=0 go test -v -p 1 -count=1 -covermode=count -coverprofile=coverage/c.out ./...
stop_test_db
echo "Test database stopped."
;;
esac