2020-06-24 09:56:04 +03:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
2023-02-08 11:29:09 +03:00
|
|
|
dialects=("sqlite" "mysql" "postgres" "sqlserver" "tidb")
|
2020-02-23 04:38:48 +03:00
|
|
|
|
|
|
|
if [[ $(pwd) == *"gorm/tests"* ]]; then
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
2020-06-19 13:44:19 +03:00
|
|
|
if [ -d tests ]
|
|
|
|
then
|
|
|
|
cd tests
|
2021-10-13 09:41:33 +03:00
|
|
|
go get -u -t ./...
|
2021-03-24 11:44:51 +03:00
|
|
|
go mod download
|
2021-06-11 11:00:26 +03:00
|
|
|
go mod tidy
|
2020-06-19 13:44:19 +03:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
2022-01-30 17:00:56 +03:00
|
|
|
# SqlServer for Mac M1
|
2024-11-21 12:03:31 +03:00
|
|
|
if [[ -z $GITHUB_ACTION && -d tests ]]; then
|
|
|
|
cd tests
|
|
|
|
if [[ $(uname -a) == *" arm64" ]]; then
|
|
|
|
MSSQL_IMAGE=mcr.microsoft.com/azure-sql-edge docker compose up -d --wait
|
|
|
|
go install github.com/microsoft/go-sqlcmd/cmd/sqlcmd@latest || true
|
|
|
|
for query in \
|
|
|
|
"IF DB_ID('gorm') IS NULL CREATE DATABASE gorm" \
|
|
|
|
"IF SUSER_ID (N'gorm') IS NULL CREATE LOGIN gorm WITH PASSWORD = 'LoremIpsum86';" \
|
|
|
|
"IF USER_ID (N'gorm') IS NULL CREATE USER gorm FROM LOGIN gorm; ALTER SERVER ROLE sysadmin ADD MEMBER [gorm];"
|
|
|
|
do
|
|
|
|
SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "$query" > /dev/null || true
|
|
|
|
done
|
|
|
|
else
|
|
|
|
MSSQL_IMAGE=mcr.microsoft.com/mssql/server docker compose up -d --wait
|
2022-01-30 17:00:56 +03:00
|
|
|
fi
|
2024-11-21 12:03:31 +03:00
|
|
|
cd ..
|
2022-01-30 17:00:56 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2020-02-23 04:38:48 +03:00
|
|
|
for dialect in "${dialects[@]}" ; do
|
|
|
|
if [ "$GORM_DIALECT" = "" ] || [ "$GORM_DIALECT" = "${dialect}" ]
|
|
|
|
then
|
2020-05-30 17:27:20 +03:00
|
|
|
echo "testing ${dialect}..."
|
|
|
|
|
2020-06-01 19:24:16 +03:00
|
|
|
if [ "$GORM_VERBOSE" = "" ]
|
|
|
|
then
|
2020-06-24 14:09:19 +03:00
|
|
|
GORM_DIALECT=${dialect} go test -race -count=1 ./...
|
2020-06-06 05:47:32 +03:00
|
|
|
if [ -d tests ]
|
|
|
|
then
|
|
|
|
cd tests
|
2020-06-24 14:09:19 +03:00
|
|
|
GORM_DIALECT=${dialect} go test -race -count=1 ./...
|
2020-06-06 05:47:32 +03:00
|
|
|
cd ..
|
|
|
|
fi
|
2020-02-23 04:38:48 +03:00
|
|
|
else
|
2020-06-24 14:09:19 +03:00
|
|
|
GORM_DIALECT=${dialect} go test -race -count=1 -v ./...
|
2020-06-06 05:47:32 +03:00
|
|
|
if [ -d tests ]
|
|
|
|
then
|
|
|
|
cd tests
|
2020-06-24 14:09:19 +03:00
|
|
|
GORM_DIALECT=${dialect} go test -race -count=1 -v ./...
|
2020-06-06 05:47:32 +03:00
|
|
|
cd ..
|
|
|
|
fi
|
2020-02-23 04:38:48 +03:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|