add oracle related stuff
This commit is contained in:
parent
3d1bd9d4c4
commit
f99aa2f504
30
.github/workflows/tests.yml
vendored
30
.github/workflows/tests.yml
vendored
@ -189,3 +189,33 @@ jobs:
|
||||
|
||||
- name: Tests
|
||||
run: GORM_DIALECT=sqlserver GORM_DSN="sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" ./tests/tests_all.sh
|
||||
oracle:
|
||||
needs: sqlite
|
||||
strategy:
|
||||
matrix:
|
||||
go: ['1.15', '1.14', '1.13']
|
||||
platform: [ubuntu-latest] # can not run test in macOS and windows
|
||||
runs-on: ${{ matrix.platform }}
|
||||
|
||||
services:
|
||||
oracle:
|
||||
image: stevefan1999/docker-oracle-xe:latest
|
||||
ports:
|
||||
- 9940:1521
|
||||
steps:
|
||||
- name: Set up Go 1.x
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: go mod pakcage cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('go.mod') }}
|
||||
|
||||
- name: Tests
|
||||
run: GORM_ENABLE_CACHE=true GORM_DIALECT=oracle GORM_DSN="gorm/gorm@localhost:9940/XEPDB1" ./tests/tests_all.sh
|
@ -6,6 +6,7 @@ require (
|
||||
github.com/google/uuid v1.1.1
|
||||
github.com/jinzhu/now v1.1.1
|
||||
github.com/lib/pq v1.6.0
|
||||
github.com/stevefan1999-personal/gorm-driver-oracle v0.0.0-20200830154622-da7a71b7196d
|
||||
gorm.io/driver/mysql v1.0.0
|
||||
gorm.io/driver/postgres v1.0.0
|
||||
gorm.io/driver/sqlite v1.1.0
|
||||
|
@ -1,6 +1,9 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
dialects=("sqlite" "mysql" "postgres" "sqlserver")
|
||||
dialects=("sqlite" "mysql" "postgres" "sqlserver" "oracle")
|
||||
|
||||
ORACLE_INSTANT_CLIENT_URL="https://download.oracle.com/otn_software/linux/instantclient/19600/instantclient-basic-linux.x64-19.6.0.0.0dbru.zip"
|
||||
ORACLE_INSTANT_CLIENT_FILE="instant_client.zip"
|
||||
|
||||
if [[ $(pwd) == *"gorm/tests"* ]]; then
|
||||
cd ..
|
||||
@ -17,6 +20,21 @@ fi
|
||||
for dialect in "${dialects[@]}" ; do
|
||||
if [ "$GORM_DIALECT" = "" ] || [ "$GORM_DIALECT" = "${dialect}" ]
|
||||
then
|
||||
if [[ "$dialect" =~ "oracle" ]]
|
||||
then
|
||||
if [[ ! -d $(pwd)/instantclient_19_6 ]]
|
||||
then
|
||||
if [[ ! -f "$ORACLE_INSTANT_CLIENT_FILE" ]]
|
||||
then
|
||||
echo "downloading oracle instant client..."
|
||||
curl "$ORACLE_INSTANT_CLIENT_URL" -o "$ORACLE_INSTANT_CLIENT_FILE"
|
||||
fi
|
||||
echo "unzipping oracle instant client..."
|
||||
unzip -o "$ORACLE_INSTANT_CLIENT_FILE"
|
||||
fi
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/instantclient_19_6
|
||||
echo "exported instant client libraries to LD_LIBRARY_PATH, now it should not complain about missing oracle libraries"
|
||||
fi
|
||||
echo "testing ${dialect}..."
|
||||
|
||||
if [ "$GORM_VERBOSE" = "" ]
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/stevefan1999-personal/gorm-driver-oracle"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/driver/sqlite"
|
||||
@ -71,6 +72,12 @@ func OpenTestConnection() (db *gorm.DB, err error) {
|
||||
dbDSN = "sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm"
|
||||
}
|
||||
db, err = gorm.Open(sqlserver.Open(dbDSN), &gorm.Config{})
|
||||
case "oracle":
|
||||
log.Println("testing oracle...")
|
||||
if dbDSN == "" {
|
||||
dbDSN = "gorm/gorm@localhost:9940/XEPDB1"
|
||||
}
|
||||
db, err = gorm.Open(oracle.Open(dbDSN), &gorm.Config{})
|
||||
default:
|
||||
log.Println("testing sqlite3...")
|
||||
db, err = gorm.Open(sqlite.Open(filepath.Join(os.TempDir(), "gorm.db")), &gorm.Config{})
|
||||
|
Loading…
x
Reference in New Issue
Block a user