Update test script, close #494

This commit is contained in:
Jinzhu 2022-10-09 16:10:24 +08:00
parent 40df23c279
commit 70ec454f64
4 changed files with 27 additions and 18 deletions

@ -10,18 +10,14 @@ GORM Playground can be used to play GORM and reports issues, if you encounter a
##### 2. [Clone the forked repo to your local](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/cloning-a-repository) ##### 2. [Clone the forked repo to your local](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/cloning-a-repository)
##### 3. Setup test database ##### 3. Install docker-compose
```bash https://docs.docker.com/compose/install/
# install docker-compose https://docs.docker.com/compose/install/
# setup test databases
docker-compose up
```
##### 4. Run tests with lastest GORM and all drivers ##### 4. Run tests with lastest GORM and all drivers
```bash ```bash
# run tests (retry if failed due to preparing the testing database)
./test.sh ./test.sh
# Run tests with cached GORM and latest drivers # Run tests with cached GORM and latest drivers

@ -2,7 +2,7 @@ version: '3'
services: services:
mysql: mysql:
image: 'mysql:latest' image: 'mysql/mysql-server:latest'
ports: ports:
- 9910:3306 - 9910:3306
environment: environment:
@ -20,7 +20,7 @@ services:
- POSTGRES_USER=gorm - POSTGRES_USER=gorm
- POSTGRES_PASSWORD=gorm - POSTGRES_PASSWORD=gorm
mssql: mssql:
image: 'mcmoe/mssqldocker:latest' image: '${MSSQL_IMAGE:-mcmoe/mssqldocker}:latest'
ports: ports:
- 9930:1433 - 9930:1433
environment: environment:
@ -29,4 +29,3 @@ services:
- MSSQL_DB=gorm - MSSQL_DB=gorm
- MSSQL_USER=gorm - MSSQL_USER=gorm
- MSSQL_PASSWORD=LoremIpsum86 - MSSQL_PASSWORD=LoremIpsum86

13
go.mod

@ -3,14 +3,13 @@ module gorm.io/playground
go 1.16 go 1.16
require ( require (
github.com/denisenkom/go-mssqldb v0.12.2 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/jackc/pgx/v4 v4.16.1 // indirect gorm.io/driver/mysql v1.4.1
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122 // indirect gorm.io/driver/postgres v1.4.4
gorm.io/driver/mysql v1.3.3 gorm.io/driver/sqlite v1.4.2
gorm.io/driver/postgres v1.3.5 gorm.io/driver/sqlserver v1.4.1
gorm.io/driver/sqlite v1.3.2 gorm.io/gorm v1.24.0
gorm.io/driver/sqlserver v1.3.2
gorm.io/gorm v1.23.4
) )
replace gorm.io/gorm => ./gorm replace gorm.io/gorm => ./gorm

17
test.sh

@ -9,7 +9,22 @@ fi
[ -d gorm ] || (echo "git clone --depth 1 -b $(cat main_test.go | grep GORM_BRANCH | awk '{print $3}') $(cat main_test.go | grep GORM_REPO | awk '{print $3}')"; git clone --depth 1 -b $(cat main_test.go | grep GORM_BRANCH | awk '{print $3}') $(cat main_test.go | grep GORM_REPO | awk '{print $3}')) [ -d gorm ] || (echo "git clone --depth 1 -b $(cat main_test.go | grep GORM_BRANCH | awk '{print $3}') $(cat main_test.go | grep GORM_REPO | awk '{print $3}')"; git clone --depth 1 -b $(cat main_test.go | grep GORM_BRANCH | awk '{print $3}') $(cat main_test.go | grep GORM_REPO | awk '{print $3}'))
go get -u ./... go get -u -t ./...
# SqlServer for Mac M1
if [[ -z $GITHUB_ACTION ]]; then
if [[ $(uname -a) == *" arm64" ]]; then
MSSQL_IMAGE=mcr.microsoft.com/azure-sql-edge docker-compose up --detach --quiet-pull || true
echo "starting"
go install github.com/microsoft/go-sqlcmd/cmd/sqlcmd@latest || true
SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF DB_ID('gorm') IS NULL CREATE DATABASE gorm" > /dev/null || true
SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF SUSER_ID (N'gorm') IS NULL CREATE LOGIN gorm WITH PASSWORD = 'LoremIpsum86';" > /dev/null || true
SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF USER_ID (N'gorm') IS NULL CREATE USER gorm FROM LOGIN gorm; ALTER SERVER ROLE sysadmin ADD MEMBER [gorm];" > /dev/null || true
else
docker-compose up --detach --quiet-pull
echo "starting..."
fi
fi
for dialect in "${dialects[@]}" ; do for dialect in "${dialects[@]}" ; do
if [ "$GORM_DIALECT" = "" ] || [ "$GORM_DIALECT" = "${dialect}" ] if [ "$GORM_DIALECT" = "" ] || [ "$GORM_DIALECT" = "${dialect}" ]