-
Notifications
You must be signed in to change notification settings - Fork 24
/
test
executable file
·48 lines (43 loc) · 1.18 KB
/
test
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
#!/bin/bash
DOCKER_IP=${DOCKER_IP:-127.0.0.1}
sqlite3() {
DATABASE_URI="sqlite3://file:dummy?mode=memory&cache=shared" go test -v -race -cover
return $?
}
postgres() {
VERSION=$1
ID=$(docker run \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-p 5432 -d postgres:$VERSION)
PORT=$(docker port "$ID" 5432 | cut -d : -f 2)
DATABASE_URI="postgres://user=postgres password=postgres dbname=postgres host=$DOCKER_IP port=$PORT sslmode=disable" go test -v -race -cover
S=$?
docker rm -vf "$ID" > /dev/null
return $S
}
mysql() {
VERSION=$1
ID=$(docker run \
-e MYSQL_ROOT_PASSWORD=root \
-e MYSQL_USER=mysql \
-e MYSQL_PASSWORD=mysql \
-e MYSQL_DATABASE=mysql \
-p 3306 -d mysql:$VERSION)
PORT=$(docker port "$ID" 3306 | cut -d : -f 2)
DATABASE_URI="mysql://mysql:mysql@tcp($DOCKER_IP:$PORT)/mysql?charset=utf8&parseTime=True" go test -v -race -cover
S=$?
docker rm -vf "$ID" > /dev/null
return $S
}
sqlite3 || exit 1
postgres 9.4 || exit 1
postgres 9.6 || exit 1
postgres 10 || exit 1
postgres 11 || exit 1
postgres 12 || exit 1
postgres 13 || exit 1
postgres 14 || exit 1
postgres 15 || exit 1
mysql 5.7 || exit 1
mysql 8.0 || exit 1