Skip to content

Commit

Permalink
Fix test script, close #751
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Nov 21, 2024
1 parent 4f84925 commit fabf3ff
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 34 deletions.
6 changes: 3 additions & 3 deletions gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"gorm.io/gen"
"gorm.io/gen/examples/dal"
// "gorm.io/gen/examples/dal"
)

func generate() {
Expand All @@ -12,9 +12,9 @@ func generate() {

WithUnitTest: true,
})
g.UseDB(dal.DB)
// g.UseDB(dal.DB)

g.ApplyBasic(Company{}, Language{}) // Associations
// g.ApplyBasic(Company{}, Language{}) // Associations
g.ApplyBasic(g.GenerateModel("user"), g.GenerateModelAs("account", "AccountInfo"))

g.Execute()
Expand Down
46 changes: 26 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
module gorm.io/playground

go 1.20
go 1.22.0

toolchain go1.23.3

require (
gorm.io/driver/mysql v1.5.2
gorm.io/driver/postgres v1.5.2
gorm.io/driver/sqlite v1.5.3
gorm.io/driver/sqlserver v1.5.1
gorm.io/gen v0.3.25
gorm.io/gorm v1.25.4
gorm.io/driver/mysql v1.5.7
gorm.io/driver/postgres v1.5.10
gorm.io/driver/sqlite v1.5.6
gorm.io/driver/sqlserver v1.5.4
gorm.io/gen v0.3.26
gorm.io/gorm v1.25.12
)

require (
github.com/go-sql-driver/mysql v1.7.1 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.4.3 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/microsoft/go-mssqldb v1.5.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.15.0 // indirect
gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c // indirect
gorm.io/hints v1.1.0 // indirect
gorm.io/plugin/dbresolver v1.5.0 // indirect
github.com/mattn/go-sqlite3 v1.14.24 // indirect
github.com/microsoft/go-mssqldb v1.7.2 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.27.0 // indirect
gorm.io/datatypes v1.2.4 // indirect
gorm.io/hints v1.1.2 // indirect
gorm.io/plugin/dbresolver v1.5.3 // indirect
)

replace gorm.io/gorm => ./gorm
30 changes: 19 additions & 11 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,30 @@ then
rm -rf gorm
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 $(grep GORM_BRANCH main_test.go | awk '{print $3}') $(grep GORM_REPO main_test.go | awk '{print $3}')"; git clone --depth 1 -b $(grep GORM_BRANCH main_test.go | awk '{print $3}') $(grep GORM_REPO main_test.go | awk '{print $3}'))

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..."
if [ -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
for query in \
"IF DB_ID('gorm') IS NULL CREATE DATABASE gorm" \
"IF SUSER_ID (N'gorm') IS NULL CREATE LOGIN gorm WITH PASSWORD = '${SQLCMDPASSWORD}';" \
"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
done
else
MSSQL_IMAGE=mcr.microsoft.com/mssql/server docker compose up -d --wait
fi
cd ..
fi
fi

Expand Down

0 comments on commit fabf3ff

Please sign in to comment.