forked from go-gorm/gorm
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): support pure-go sqlite driver
This tests the sqlite with/out CGO, updates the minimum tests go version to 1.18, and adds the latest go version `^1` to the sqlite CI tests. Related: go-gorm/sqlite#161
- Loading branch information
1 parent
2066138
commit 4dc37c0
Showing
3 changed files
with
84 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,47 @@ | ||
module gorm.io/gorm/tests | ||
|
||
go 1.16 | ||
go 1.18 | ||
|
||
require ( | ||
github.com/google/uuid v1.3.0 | ||
github.com/jackc/pgx/v5 v5.3.1 // indirect | ||
github.com/jinzhu/now v1.1.5 | ||
github.com/lib/pq v1.10.8 | ||
github.com/mattn/go-sqlite3 v1.14.16 // indirect | ||
gorm.io/driver/mysql v1.5.0 | ||
gorm.io/driver/postgres v1.5.0 | ||
gorm.io/driver/sqlite v1.5.0 | ||
github.com/lib/pq v1.10.9 | ||
gorm.io/driver/mysql v1.5.1 | ||
gorm.io/driver/postgres v1.5.2 | ||
gorm.io/driver/sqlite v1.5.2 | ||
gorm.io/driver/sqlserver v1.5.1 | ||
gorm.io/gorm v1.25.1 | ||
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 | ||
) | ||
|
||
require ( | ||
github.com/dustin/go-humanize v1.0.1 // indirect | ||
github.com/go-sql-driver/mysql v1.7.1 // indirect | ||
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect | ||
github.com/golang-sql/sqlexp v0.1.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.1 // indirect | ||
github.com/jinzhu/inflection v1.0.0 // indirect | ||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect | ||
github.com/mattn/go-isatty v0.0.16 // indirect | ||
github.com/mattn/go-sqlite3 v1.14.17 // indirect | ||
github.com/microsoft/go-mssqldb v1.3.0 // indirect | ||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect | ||
golang.org/x/crypto v0.11.0 // indirect | ||
golang.org/x/mod v0.8.0 // indirect | ||
golang.org/x/sys v0.10.0 // indirect | ||
golang.org/x/text v0.11.0 // indirect | ||
golang.org/x/tools v0.6.0 // indirect | ||
lukechampine.com/uint128 v1.2.0 // indirect | ||
modernc.org/cc/v3 v3.40.0 // indirect | ||
modernc.org/ccgo/v3 v3.16.13 // indirect | ||
modernc.org/libc v1.22.5 // indirect | ||
modernc.org/mathutil v1.5.0 // indirect | ||
modernc.org/memory v1.5.0 // indirect | ||
modernc.org/opt v0.1.3 // indirect | ||
modernc.org/sqlite v1.23.1 // indirect | ||
modernc.org/strutil v1.1.3 // indirect | ||
modernc.org/token v1.0.1 // indirect | ||
) | ||
|
||
replace gorm.io/gorm => ../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,54 @@ | ||
#!/bin/bash -e | ||
|
||
dialects=("sqlite" "mysql" "postgres" "sqlserver" "tidb") | ||
dialects=("sqlite") | ||
|
||
if [[ $(pwd) == *"gorm/tests"* ]]; then | ||
cd .. | ||
cd .. | ||
fi | ||
|
||
if [ -d tests ] | ||
then | ||
cd tests | ||
go get -u -t ./... | ||
go mod download | ||
go mod tidy | ||
cd .. | ||
if [ -d tests ]; then | ||
cd tests | ||
go get -u -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('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 start | ||
fi | ||
cd .. | ||
fi | ||
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('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 start | ||
fi | ||
cd .. | ||
fi | ||
fi | ||
|
||
for dialect in "${dialects[@]}"; do | ||
if [ "$GORM_DIALECT" = "" ] || [ "$GORM_DIALECT" = "${dialect}" ]; then | ||
echo "testing ${dialect}..." | ||
|
||
for dialect in "${dialects[@]}" ; do | ||
if [ "$GORM_DIALECT" = "" ] || [ "$GORM_DIALECT" = "${dialect}" ] | ||
then | ||
echo "testing ${dialect}..." | ||
|
||
if [ "$GORM_VERBOSE" = "" ] | ||
then | ||
GORM_DIALECT=${dialect} go test -race -count=1 ./... | ||
if [ -d tests ] | ||
then | ||
cd tests | ||
GORM_DIALECT=${dialect} go test -race -count=1 ./... | ||
cd .. | ||
fi | ||
else | ||
GORM_DIALECT=${dialect} go test -race -count=1 -v ./... | ||
if [ -d tests ] | ||
then | ||
cd tests | ||
GORM_DIALECT=${dialect} go test -race -count=1 -v ./... | ||
cd .. | ||
fi | ||
fi | ||
fi | ||
if [ "$GORM_VERBOSE" = "" ]; then | ||
GORM_DIALECT=${dialect} go test -race -count=1 ./... | ||
if [ -d tests ]; then | ||
cd tests | ||
GORM_DIALECT=${dialect} go test -race -count=1 ./... | ||
cd .. | ||
fi | ||
else | ||
GORM_DIALECT=${dialect} go test -race -count=1 -v ./... | ||
if [ -d tests ]; then | ||
cd tests | ||
GORM_DIALECT=${dialect} go test -race -count=1 -v ./... | ||
cd .. | ||
fi | ||
fi | ||
fi | ||
done |