Update circle.ci
This commit is contained in:
parent
972fc1d9bf
commit
b92af7ca6e
9 changed files with 128 additions and 127 deletions
|
|
@ -1,28 +1,37 @@
|
||||||
# Golang CircleCI 2.0 configuration file
|
# Golang CircleCI 2.0 configuration file
|
||||||
#
|
#
|
||||||
# Check https://circleci.com/docs/2.0/language-go/ for more details
|
# Check https://circleci.com/docs/2.0/language-go/ for more details
|
||||||
version: 2
|
version: 2.1
|
||||||
|
orbs:
|
||||||
|
codecov: codecov/codecov@3.1.1
|
||||||
jobs:
|
jobs:
|
||||||
build-postgres-and-mysql:
|
build_and_tests:
|
||||||
docker:
|
docker:
|
||||||
# specify the version
|
# specify the version
|
||||||
- image: circleci/golang:1.13
|
- image: circleci/golang:1.16
|
||||||
|
- image: circleci/postgres:12
|
||||||
- image: circleci/postgres:10.8-alpine
|
environment:
|
||||||
environment: # environment variables for primary container
|
|
||||||
POSTGRES_USER: jet
|
POSTGRES_USER: jet
|
||||||
POSTGRES_PASSWORD: jet
|
POSTGRES_PASSWORD: jet
|
||||||
POSTGRES_DB: jetdb
|
POSTGRES_DB: jetdb
|
||||||
|
PGPORT: 50901
|
||||||
|
|
||||||
- image: circleci/mysql:8.0.16
|
- image: circleci/mysql:8.0.27
|
||||||
command: [--default-authentication-plugin=mysql_native_password]
|
command: [ --default-authentication-plugin=mysql_native_password ]
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: jet
|
MYSQL_ROOT_PASSWORD: jet
|
||||||
MYSQL_DATABASE: dvds
|
MYSQL_DATABASE: dvds
|
||||||
MYSQL_USER: jet
|
MYSQL_USER: jet
|
||||||
MYSQL_PASSWORD: jet
|
MYSQL_PASSWORD: jet
|
||||||
|
MYSQL_TCP_PORT: 50902
|
||||||
|
|
||||||
working_directory: /go/src/github.com/go-jet/jet
|
- image: circleci/mariadb:10.3
|
||||||
|
command: [ '--default-authentication-plugin=mysql_native_password', '--port=50903' ]
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: jet
|
||||||
|
MYSQL_DATABASE: dvds
|
||||||
|
MYSQL_USER: jet
|
||||||
|
MYSQL_PASSWORD: jet
|
||||||
|
|
||||||
environment: # environment variables for the build itself
|
environment: # environment variables for the build itself
|
||||||
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
|
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
|
||||||
|
|
@ -32,25 +41,22 @@ jobs:
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Submodule init
|
name: Submodule init
|
||||||
command: |
|
command: cd tests && make checkout-testdata
|
||||||
git submodule init
|
|
||||||
git submodule update
|
|
||||||
cd ./tests/testdata && git fetch && git checkout master
|
|
||||||
|
|
||||||
|
- restore_cache: # restores saved cache if no changes are detected since last run
|
||||||
|
keys:
|
||||||
|
- go-mod-v4-{{ checksum "go.sum" }}
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Install dependencies
|
name: Install jet generator
|
||||||
command: |
|
command: cd tests && make install-jet-gen
|
||||||
cd /go/src/github.com/go-jet/jet
|
|
||||||
go get github.com/jstemmer/go-junit-report
|
|
||||||
go build -o /home/circleci/.local/bin/jet ./cmd/jet/
|
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Waiting for Postgres to be ready
|
name: Waiting for Postgres to be ready
|
||||||
command: |
|
command: |
|
||||||
for i in `seq 1 10`;
|
for i in `seq 1 10`;
|
||||||
do
|
do
|
||||||
nc -z localhost 5432 && echo Success && exit 0
|
nc -z localhost 50901 && echo Success && exit 0
|
||||||
echo -n .
|
echo -n .
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
@ -61,39 +67,71 @@ jobs:
|
||||||
command: |
|
command: |
|
||||||
for i in `seq 1 10`;
|
for i in `seq 1 10`;
|
||||||
do
|
do
|
||||||
nc -z 127.0.0.1 3306 && echo Success && exit 0
|
nc -z 127.0.0.1 50902 && echo Success && exit 0
|
||||||
echo -n .
|
echo -n .
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
echo Failed waiting for MySQL && exit 1
|
echo Failed waiting for MySQL && exit 1
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Waiting for MariaDB to be ready
|
||||||
|
command: |
|
||||||
|
for i in `seq 1 10`;
|
||||||
|
do
|
||||||
|
nc -z 127.0.0.1 50903 && echo Success && exit 0
|
||||||
|
echo -n .
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echo Failed waiting for MySQL && exit 1
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Install MySQL CLI;
|
name: Install MySQL CLI;
|
||||||
command: |
|
command: |
|
||||||
sudo apt-get --allow-releaseinfo-change update && sudo apt-get install default-mysql-client
|
sudo apt-get --allow-releaseinfo-change update && sudo apt-get install default-mysql-client
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Create MySQL user and databases
|
name: Create MySQL/MariaDB user and test databases
|
||||||
command: |
|
command: |
|
||||||
mysql -h 127.0.0.1 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
|
mysql -h 127.0.0.1 -P 50902 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
|
||||||
mysql -h 127.0.0.1 -u root -pjet -e "set global sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';"
|
mysql -h 127.0.0.1 -P 50902 -u root -pjet -e "set global sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';"
|
||||||
mysql -h 127.0.0.1 -u jet -pjet -e "create database test_sample"
|
mysql -h 127.0.0.1 -P 50902 -u jet -pjet -e "create database test_sample"
|
||||||
mysql -h 127.0.0.1 -u jet -pjet -e "create database dvds2"
|
mysql -h 127.0.0.1 -P 50902 -u jet -pjet -e "create database dvds2"
|
||||||
|
|
||||||
|
mysql -h 127.0.0.1 -P 50903 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
|
||||||
|
mysql -h 127.0.0.1 -P 50903 -u root -pjet -e "set global sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';"
|
||||||
|
mysql -h 127.0.0.1 -P 50903 -u jet -pjet -e "create database test_sample"
|
||||||
|
mysql -h 127.0.0.1 -P 50903 -u jet -pjet -e "create database dvds2"
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Init Postgres database
|
name: Init databases
|
||||||
command: |
|
command: |
|
||||||
cd tests
|
cd tests
|
||||||
go run ./init/init.go -testsuite all
|
go run ./init/init.go -testsuite all
|
||||||
cd ..
|
|
||||||
|
|
||||||
|
# to create test results report
|
||||||
|
- run:
|
||||||
|
name: Install go-junit-report
|
||||||
|
command: go install github.com/jstemmer/go-junit-report@latest
|
||||||
|
|
||||||
- run: mkdir -p $TEST_RESULTS
|
- run: mkdir -p $TEST_RESULTS
|
||||||
# this will run all tests and exclude test files from code coverage report
|
|
||||||
- run: MY_SQL_SOURCE=MySQL go test -v ./... -covermode=atomic -coverpkg=github.com/go-jet/jet/postgres/...,github.com/go-jet/jet/mysql/...,github.com/go-jet/jet/sqlite/...,github.com/go-jet/jet/qrm/...,github.com/go-jet/jet/generator/...,github.com/go-jet/jet/internal/... -coverprofile=cover.out 2>&1 | go-junit-report > $TEST_RESULTS/results.xml
|
|
||||||
|
|
||||||
- run:
|
# this will run all tests and exclude test files from code coverage report
|
||||||
name: Upload code coverage
|
- run: |
|
||||||
command: bash <(curl -s https://codecov.io/bash)
|
go test -v ./... \
|
||||||
|
-covermode=atomic \
|
||||||
|
-coverpkg=github.com/go-jet/jet/v2/postgres/...,github.com/go-jet/jet/v2/mysql/...,github.com/go-jet/jet/v2/sqlite/...,github.com/go-jet/jet/v2/qrm/...,github.com/go-jet/jet/v2/generator/...,github.com/go-jet/jet/v2/internal/... \
|
||||||
|
-coverprofile=cover.out 2>&1 | go-junit-report > $TEST_RESULTS/results.xml
|
||||||
|
|
||||||
|
# run mariaDB tests. No need to collect coverage, because coverage is already included with mysql tests
|
||||||
|
- run: MY_SQL_SOURCE=MariaDB go test -v ./tests/mysql/
|
||||||
|
|
||||||
|
- save_cache:
|
||||||
|
key: go-mod-v4-{{ checksum "go.sum" }}
|
||||||
|
paths:
|
||||||
|
- "/go/pkg/mod"
|
||||||
|
|
||||||
|
- codecov/upload:
|
||||||
|
file: cover.out
|
||||||
|
|
||||||
- store_artifacts: # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
|
- store_artifacts: # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
|
||||||
path: /tmp/test-results
|
path: /tmp/test-results
|
||||||
|
|
@ -101,69 +139,9 @@ jobs:
|
||||||
|
|
||||||
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
|
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
|
||||||
path: /tmp/test-results
|
path: /tmp/test-results
|
||||||
build-mariadb:
|
|
||||||
docker:
|
|
||||||
# specify the version
|
|
||||||
- image: circleci/golang:1.13
|
|
||||||
|
|
||||||
- image: circleci/mariadb:10.3
|
|
||||||
command: [--default-authentication-plugin=mysql_native_password]
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: jet
|
|
||||||
MYSQL_DATABASE: dvds
|
|
||||||
MYSQL_USER: jet
|
|
||||||
MYSQL_PASSWORD: jet
|
|
||||||
|
|
||||||
working_directory: /go/src/github.com/go-jet/jet
|
|
||||||
|
|
||||||
environment: # environment variables for the build itself
|
|
||||||
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Submodule init
|
|
||||||
command: |
|
|
||||||
git submodule init
|
|
||||||
git submodule update
|
|
||||||
cd ./tests/testdata && git fetch && git checkout master
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Install dependencies
|
|
||||||
command: |
|
|
||||||
cd /go/src/github.com/go-jet/jet
|
|
||||||
go get github.com/jstemmer/go-junit-report
|
|
||||||
go build -o /home/circleci/.local/bin/jet ./cmd/jet/
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Install MySQL CLI;
|
|
||||||
command: |
|
|
||||||
sudo apt-get --allow-releaseinfo-change update && sudo apt-get install default-mysql-client
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Init MariaDB database
|
|
||||||
command: |
|
|
||||||
mysql -h 127.0.0.1 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
|
|
||||||
mysql -h 127.0.0.1 -u root -pjet -e "set global sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';"
|
|
||||||
mysql -h 127.0.0.1 -u jet -pjet -e "create database test_sample"
|
|
||||||
mysql -h 127.0.0.1 -u jet -pjet -e "create database dvds2"
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Init MariaDB database
|
|
||||||
command: |
|
|
||||||
cd tests
|
|
||||||
go run ./init/init.go -testsuite MariaDB
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Run MariaDB tests
|
|
||||||
command: |
|
|
||||||
MY_SQL_SOURCE=MariaDB go test -v ./tests/mysql/
|
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
build_and_test:
|
build_and_test:
|
||||||
jobs:
|
jobs:
|
||||||
- build-postgres-and-mysql
|
- build_and_tests
|
||||||
- build-mariadb
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -21,3 +21,4 @@ gen
|
||||||
.tests/testdata/
|
.tests/testdata/
|
||||||
.gen
|
.gen
|
||||||
.docker
|
.docker
|
||||||
|
.env
|
||||||
|
|
@ -14,14 +14,28 @@ checkout-testdata:
|
||||||
docker-compose-up:
|
docker-compose-up:
|
||||||
docker-compose up
|
docker-compose up
|
||||||
|
|
||||||
|
init-all:
|
||||||
|
go run ./init/init.go -testsuite all
|
||||||
|
|
||||||
|
init-postgres:
|
||||||
|
go run ./init/init.go -testsuite postgres
|
||||||
|
|
||||||
|
init-mysql:
|
||||||
|
go run ./init/init.go -testsuite mysql
|
||||||
|
|
||||||
|
init-mariadb:
|
||||||
|
go run ./init/init.go -testsuite mariadb
|
||||||
|
|
||||||
|
init-sqlite:
|
||||||
|
go run ./init/init.go -testsuite sqlite
|
||||||
|
|
||||||
# jet-gen will call generator on each of the test databases to generate sql builder and model files need to run the tests.
|
# jet-gen will call generator on each of the test databases to generate sql builder and model files need to run the tests.
|
||||||
jet-gen: install-jet-gen jet-gen-pg jet-gen-mysql jet-gen-mariadb jet-gen-sqlite
|
jet-gen-all: install-jet-gen jet-gen-postgres jet-gen-mysql jet-gen-mariadb jet-gen-sqlite
|
||||||
|
|
||||||
install-jet-gen:
|
install-jet-gen:
|
||||||
go build -o ${GOPATH}/bin/jet ../cmd/jet/
|
go build -o ${GOPATH}/bin/jet ../cmd/jet/
|
||||||
|
|
||||||
jet-gen-pg:
|
jet-gen-postgres:
|
||||||
jet -dsn=postgres://jet:jet@localhost:50901/jetdb?sslmode=disable -schema=dvds -path=./.gentestdata/
|
jet -dsn=postgres://jet:jet@localhost:50901/jetdb?sslmode=disable -schema=dvds -path=./.gentestdata/
|
||||||
jet -dsn=postgres://jet:jet@localhost:50901/jetdb?sslmode=disable -schema=chinook -path=./.gentestdata/
|
jet -dsn=postgres://jet:jet@localhost:50901/jetdb?sslmode=disable -schema=chinook -path=./.gentestdata/
|
||||||
jet -dsn=postgres://jet:jet@localhost:50901/jetdb?sslmode=disable -schema=chinook2 -path=./.gentestdata/
|
jet -dsn=postgres://jet:jet@localhost:50901/jetdb?sslmode=disable -schema=chinook2 -path=./.gentestdata/
|
||||||
|
|
@ -44,7 +58,5 @@ jet-gen-sqlite:
|
||||||
|
|
||||||
|
|
||||||
# docker-compose-cleanup will stop and remove test containers, volumes, and images.
|
# docker-compose-cleanup will stop and remove test containers, volumes, and images.
|
||||||
# If temp .docker/ folder is still not empty, use 'sudo rm -rf .docker' to remove it.
|
|
||||||
cleanup:
|
cleanup:
|
||||||
docker-compose down --volumes
|
docker-compose down --volumes
|
||||||
$(info INFO: If the ./.docker folder is still not empty, use 'sudo rm -rf .docker/' to remove it.)
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ To simplify the process there is a Makefile with a list of helper commands.
|
||||||
# Note that on the first run this command might take a couple of minutes.
|
# Note that on the first run this command might take a couple of minutes.
|
||||||
make setup
|
make setup
|
||||||
|
|
||||||
# When databases are ready, we can generate sql builder and model types needed to compile the tests.
|
# When databases are ready, we can generate sql builder and model types for each of the test databases
|
||||||
make jet-gen
|
make jet-gen-all
|
||||||
```
|
```
|
||||||
|
|
||||||
Then we can run the tests the usual way:
|
Then we can run the tests the usual way:
|
||||||
|
|
@ -26,5 +26,4 @@ go test -v ./...
|
||||||
To removes test containers, volumes, and images:
|
To removes test containers, volumes, and images:
|
||||||
```shell
|
```shell
|
||||||
make cleanup
|
make cleanup
|
||||||
# If temp ./.docker folder is still not empty, use 'sudo rm -rf .docker' to remove it.
|
|
||||||
```
|
```
|
||||||
|
|
@ -19,12 +19,12 @@ var PostgresConnectString = fmt.Sprintf("host=%s port=%d user=%s password=%s dbn
|
||||||
|
|
||||||
// MySQL test database connection parameters
|
// MySQL test database connection parameters
|
||||||
const (
|
const (
|
||||||
MySqLHost = "localhost"
|
MySqLHost = "127.0.0.1"
|
||||||
MySQLPort = 50902
|
MySQLPort = 50902
|
||||||
MySQLUser = "jet"
|
MySQLUser = "jet"
|
||||||
MySQLPassword = "jet"
|
MySQLPassword = "jet"
|
||||||
|
|
||||||
MariaDBHost = "localhost"
|
MariaDBHost = "127.0.0.1"
|
||||||
MariaDBPort = 50903
|
MariaDBPort = 50903
|
||||||
MariaDBUser = "jet"
|
MariaDBUser = "jet"
|
||||||
MariaDBPassword = "jet"
|
MariaDBPassword = "jet"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ services:
|
||||||
- '50901:5432'
|
- '50901:5432'
|
||||||
volumes:
|
volumes:
|
||||||
- ./testdata/init/postgres:/docker-entrypoint-initdb.d
|
- ./testdata/init/postgres:/docker-entrypoint-initdb.d
|
||||||
- ./.docker/postgres-data:/var/lib/postgresql/data
|
|
||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:8.0.27
|
image: mysql:8.0.27
|
||||||
|
|
@ -25,7 +24,6 @@ services:
|
||||||
- '50902:3306'
|
- '50902:3306'
|
||||||
volumes:
|
volumes:
|
||||||
- ./testdata/init/mysql:/docker-entrypoint-initdb.d
|
- ./testdata/init/mysql:/docker-entrypoint-initdb.d
|
||||||
- ./.docker/mysql-data:/var/lib/mysql
|
|
||||||
|
|
||||||
mariadb:
|
mariadb:
|
||||||
image: mariadb:10.3.32
|
image: mariadb:10.3.32
|
||||||
|
|
@ -39,4 +37,3 @@ services:
|
||||||
- '50903:3306'
|
- '50903:3306'
|
||||||
volumes:
|
volumes:
|
||||||
- ./testdata/init/mysql:/docker-entrypoint-initdb.d
|
- ./testdata/init/mysql:/docker-entrypoint-initdb.d
|
||||||
- ./.docker/mariadb-data:/var/lib/mysql
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/go-jet/jet/v2/generator/mysql"
|
||||||
"github.com/go-jet/jet/v2/generator/sqlite"
|
"github.com/go-jet/jet/v2/generator/sqlite"
|
||||||
"github.com/go-jet/jet/v2/tests/internal/utils/repo"
|
"github.com/go-jet/jet/v2/tests/internal/utils/repo"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
@ -11,7 +12,6 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-jet/jet/v2/generator/mysql"
|
|
||||||
"github.com/go-jet/jet/v2/generator/postgres"
|
"github.com/go-jet/jet/v2/generator/postgres"
|
||||||
"github.com/go-jet/jet/v2/internal/utils/throw"
|
"github.com/go-jet/jet/v2/internal/utils/throw"
|
||||||
"github.com/go-jet/jet/v2/tests/dbconfig"
|
"github.com/go-jet/jet/v2/tests/dbconfig"
|
||||||
|
|
@ -39,7 +39,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if testSuite == "mysql" || testSuite == "mariadb" {
|
if testSuite == "mysql" || testSuite == "mariadb" {
|
||||||
initMySQLDB()
|
initMySQLDB(testSuite == "mariadb")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,8 +48,9 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
initMySQLDB()
|
|
||||||
initPostgresDB()
|
initPostgresDB()
|
||||||
|
initMySQLDB(false)
|
||||||
|
initMySQLDB(true)
|
||||||
initSQLiteDB()
|
initSQLiteDB()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +63,7 @@ func initSQLiteDB() {
|
||||||
throw.OnError(err)
|
throw.OnError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initMySQLDB() {
|
func initMySQLDB(isMariaDB bool) {
|
||||||
|
|
||||||
mySQLDBs := []string{
|
mySQLDBs := []string{
|
||||||
"dvds",
|
"dvds",
|
||||||
|
|
@ -71,12 +72,19 @@ func initMySQLDB() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dbName := range mySQLDBs {
|
for _, dbName := range mySQLDBs {
|
||||||
cmdLine := fmt.Sprintf("mysql -h %s -P%d -u %s -p%s %s < %s",
|
host := dbconfig.MySqLHost
|
||||||
dbconfig.MySqLHost,
|
port := dbconfig.MySQLPort
|
||||||
dbconfig.MySQLPort,
|
user := dbconfig.MySQLUser
|
||||||
dbconfig.MySQLUser,
|
pass := dbconfig.MySQLPassword
|
||||||
dbconfig.MySQLPassword,
|
|
||||||
dbName,
|
if isMariaDB {
|
||||||
|
host = dbconfig.MariaDBHost
|
||||||
|
port = dbconfig.MariaDBPort
|
||||||
|
user = dbconfig.MariaDBUser
|
||||||
|
pass = dbconfig.MariaDBPassword
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdLine := fmt.Sprintf("mysql -h %s -P %d -u %s -p%s %s < %s", host, port, user, pass, dbName,
|
||||||
"./testdata/init/mysql/"+dbName+".sql")
|
"./testdata/init/mysql/"+dbName+".sql")
|
||||||
|
|
||||||
fmt.Println(cmdLine)
|
fmt.Println(cmdLine)
|
||||||
|
|
@ -90,10 +98,10 @@ func initMySQLDB() {
|
||||||
throw.OnError(err)
|
throw.OnError(err)
|
||||||
|
|
||||||
err = mysql.Generate("./.gentestdata/mysql", mysql.DBConnection{
|
err = mysql.Generate("./.gentestdata/mysql", mysql.DBConnection{
|
||||||
Host: dbconfig.MySqLHost,
|
Host: host,
|
||||||
Port: dbconfig.MySQLPort,
|
Port: port,
|
||||||
User: dbconfig.MySQLUser,
|
User: user,
|
||||||
Password: dbconfig.MySQLPassword,
|
Password: pass,
|
||||||
DBName: dbName,
|
DBName: dbName,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -104,7 +112,7 @@ func initMySQLDB() {
|
||||||
func initPostgresDB() {
|
func initPostgresDB() {
|
||||||
db, err := sql.Open("postgres", dbconfig.PostgresConnectString)
|
db, err := sql.Open("postgres", dbconfig.PostgresConnectString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Failed to connect to test db")
|
panic("Failed to connect to test db: " + err.Error())
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
err := db.Close()
|
err := db.Close()
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ var defaultActorSQLBuilderFilePath = path.Join(tempTestDir, "jetdb/dvds/table",
|
||||||
|
|
||||||
var dbConnection = postgres.DBConnection{
|
var dbConnection = postgres.DBConnection{
|
||||||
Host: dbconfig.PgHost,
|
Host: dbconfig.PgHost,
|
||||||
Port: 5432,
|
Port: dbconfig.PgPort,
|
||||||
User: dbconfig.PgUser,
|
User: dbconfig.PgUser,
|
||||||
Password: dbconfig.PgPassword,
|
Password: dbconfig.PgPassword,
|
||||||
DBName: dbconfig.PgDBName,
|
DBName: dbconfig.PgDBName,
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-jet/jet/v2/generator/postgres"
|
"github.com/go-jet/jet/v2/generator/postgres"
|
||||||
|
|
@ -52,8 +53,13 @@ func TestCmdGenerator(t *testing.T) {
|
||||||
err := os.RemoveAll(genTestDir2)
|
err := os.RemoveAll(genTestDir2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
cmd := exec.Command("jet", "-source=PostgreSQL", "-dbname=jetdb", "-host=localhost", "-port=5432",
|
cmd := exec.Command("jet", "-source=PostgreSQL", "-dbname=jetdb", "-host=localhost",
|
||||||
"-user=jet", "-password=jet", "-schema=dvds", "-path="+genTestDir2)
|
"-port="+strconv.Itoa(dbconfig.PgPort),
|
||||||
|
"-user=jet",
|
||||||
|
"-password=jet",
|
||||||
|
"-schema=dvds",
|
||||||
|
"-path="+genTestDir2)
|
||||||
|
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue