forked from go-gorm/gen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·59 lines (53 loc) · 1.53 KB
/
test.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash -e
# dialects=("sqlite" "mysql" "postgres" "sqlserver")
dialects=("mysql")
if [[ $(pwd) == *"gen/tests"* ]]; then
cd ..
fi
if [ -d tests ]
then
cd tests
go get -t ./...
go mod download
go mod tidy
cd ..
fi
# SqlServer for Mac M1
if [[ -z $GITHUB_ACTION ]]; then
if [ -d tests ]
then
cd tests
if [[ $(uname -a) == *" arm64" ]]; then
MSSQL_IMAGE=mcr.microsoft.com/azure-sql-edge docker-compose start || true
go install github.com/microsoft/go-sqlcmd/cmd/sqlcmd@latest || true
SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF DB_ID('gen') IS NULL CREATE DATABASE gen" > /dev/null || true
SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF SUSER_ID (N'gen') IS NULL CREATE LOGIN gen WITH PASSWORD = 'LoremIpsum86';" > /dev/null || true
SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF USER_ID (N'gen') IS NULL CREATE USER gen FROM LOGIN gen; ALTER SERVER ROLE sysadmin ADD MEMBER [gen];" > /dev/null || true
else
docker-compose start
fi
cd ..
fi
fi
for dialect in "${dialects[@]}" ; do
if [ "$GORM_DIALECT" = "" ] || [ "$GORM_DIALECT" = "${dialect}" ]
then
echo "testing ${dialect}..."
if [ "$GEN_VERBOSE" = "" ]
then
if [ -d tests ]
then
cd tests
GORM_DIALECT=${dialect} go test -race -count=1 ./...
cd ..
fi
else
if [ -d tests ]
then
cd tests
GORM_DIALECT=${dialect} go test -race -count=1 -v ./...
cd ..
fi
fi
fi
done