Add makefile (#1531)
Fix drone Fix ci Add deps Improve drone Fix envs Add makefile Reviewed-on: https://gitea.com/xorm/xorm/pulls/1531
This commit is contained in:
parent
bc9947c62b
commit
22aef2cd32
|
@ -1,61 +0,0 @@
|
||||||
# Golang CircleCI 2.0 configuration file
|
|
||||||
#
|
|
||||||
# Check https://circleci.com/docs/2.0/language-go/ for more details
|
|
||||||
version: 2
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
docker:
|
|
||||||
# specify the version
|
|
||||||
- image: circleci/golang:1.10
|
|
||||||
|
|
||||||
- image: circleci/mysql:5.7
|
|
||||||
environment:
|
|
||||||
MYSQL_ALLOW_EMPTY_PASSWORD: true
|
|
||||||
MYSQL_DATABASE: xorm_test
|
|
||||||
MYSQL_HOST: 127.0.0.1
|
|
||||||
MYSQL_ROOT_HOST: '%'
|
|
||||||
MYSQL_USER: root
|
|
||||||
|
|
||||||
# CircleCI PostgreSQL images available at: https://hub.docker.com/r/circleci/postgres/
|
|
||||||
- image: circleci/postgres:9.6.2-alpine
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: circleci
|
|
||||||
POSTGRES_DB: xorm_test
|
|
||||||
|
|
||||||
- image: microsoft/mssql-server-linux:latest
|
|
||||||
environment:
|
|
||||||
ACCEPT_EULA: Y
|
|
||||||
SA_PASSWORD: yourStrong(!)Password
|
|
||||||
MSSQL_PID: Developer
|
|
||||||
|
|
||||||
- image: pingcap/tidb:v2.1.2
|
|
||||||
|
|
||||||
working_directory: /go/src/github.com/go-xorm/xorm
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
|
|
||||||
- run: go get -t -d -v ./...
|
|
||||||
- run: go get -u xorm.io/core
|
|
||||||
- run: go get -u xorm.io/builder
|
|
||||||
- run: GO111MODULE=off go build -v
|
|
||||||
- run: GO111MODULE=on go build -v
|
|
||||||
|
|
||||||
- run: go get -u github.com/wadey/gocovmerge
|
|
||||||
|
|
||||||
- run: go test -v -race -db="sqlite3" -conn_str="./test.db" -coverprofile=coverage1-1.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="sqlite3" -conn_str="./test.db" -cache=true -coverprofile=coverage1-2.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="mysql" -conn_str="root:@/xorm_test" -coverprofile=coverage2-1.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="mysql" -conn_str="root:@/xorm_test" -cache=true -coverprofile=coverage2-2.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="mymysql" -conn_str="xorm_test/root/" -coverprofile=coverage3-1.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="mymysql" -conn_str="xorm_test/root/" -cache=true -coverprofile=coverage3-2.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="postgres" -conn_str="dbname=xorm_test sslmode=disable" -coverprofile=coverage4-1.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="postgres" -conn_str="dbname=xorm_test sslmode=disable" -cache=true -coverprofile=coverage4-2.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="postgres" -conn_str="dbname=xorm_test sslmode=disable" -schema=xorm -coverprofile=coverage5-1.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="postgres" -conn_str="dbname=xorm_test sslmode=disable" -schema=xorm -cache=true -coverprofile=coverage5-2.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="mssql" -conn_str="server=localhost;user id=sa;password=yourStrong(!)Password;database=xorm_test" -coverprofile=coverage6-1.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="mssql" -conn_str="server=localhost;user id=sa;password=yourStrong(!)Password;database=xorm_test" -cache=true -coverprofile=coverage6-2.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="mysql" -conn_str="root:@tcp(localhost:4000)/xorm_test" -ignore_select_update=true -coverprofile=coverage7-1.txt -covermode=atomic
|
|
||||||
- run: go test -v -race -db="mysql" -conn_str="root:@tcp(localhost:4000)/xorm_test" -ignore_select_update=true -cache=true -coverprofile=coverage7-2.txt -covermode=atomic
|
|
||||||
- run: gocovmerge coverage1-1.txt coverage1-2.txt coverage2-1.txt coverage2-2.txt coverage3-1.txt coverage3-2.txt coverage4-1.txt coverage4-2.txt coverage5-1.txt coverage5-2.txt coverage6-1.txt coverage6-2.txt coverage7-1.txt coverage7-2.txt > coverage.txt
|
|
||||||
|
|
||||||
- run: bash <(curl -s https://codecov.io/bash)
|
|
240
.drone.yml
240
.drone.yml
|
@ -3,7 +3,6 @@ kind: pipeline
|
||||||
name: testing
|
name: testing
|
||||||
steps:
|
steps:
|
||||||
- name: test-vet
|
- name: test-vet
|
||||||
pull: default
|
|
||||||
image: golang:1.12
|
image: golang:1.12
|
||||||
environment:
|
environment:
|
||||||
GO111MODULE: "on"
|
GO111MODULE: "on"
|
||||||
|
@ -16,44 +15,106 @@ steps:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
- name: test-sqlite
|
- name: test-sqlite
|
||||||
pull: default
|
|
||||||
image: golang:1.12
|
image: golang:1.12
|
||||||
environment:
|
environment:
|
||||||
GO111MODULE: "on"
|
GO111MODULE: "on"
|
||||||
GOPROXY: "https://goproxy.cn"
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_CACHE_ENABLE: false
|
||||||
commands:
|
commands:
|
||||||
- "go test -v -race -db=\"sqlite3\" -conn_str=\"./test.db\" -coverprofile=coverage1-1.txt -covermode=atomic"
|
- make test-sqlite
|
||||||
- "go test -v -race -db=\"sqlite3\" -conn_str=\"./test.db\" -cache=true -coverprofile=coverage1-2.txt -covermode=atomic"
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
- name: test-sqlite-cache
|
||||||
|
image: golang:1.12
|
||||||
|
depends_on:
|
||||||
|
- test-sqlite
|
||||||
|
environment:
|
||||||
|
GO111MODULE: "on"
|
||||||
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_CACHE_ENABLE: true
|
||||||
|
commands:
|
||||||
|
- make test-sqlite
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
- name: test-mysql
|
- name: test-mysql
|
||||||
pull: default
|
|
||||||
image: golang:1.12
|
image: golang:1.12
|
||||||
environment:
|
environment:
|
||||||
GO111MODULE: "on"
|
GO111MODULE: "on"
|
||||||
GOPROXY: "https://goproxy.cn"
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_MYSQL_HOST: mysql
|
||||||
|
TEST_MYSQL_CHARSET: utf8
|
||||||
|
TEST_MYSQL_DBNAME: xorm_test
|
||||||
|
TEST_MYSQL_USERNAME: root
|
||||||
|
TEST_MYSQL_PASSWORD:
|
||||||
|
TEST_CACHE_ENABLE: false
|
||||||
commands:
|
commands:
|
||||||
- "go test -v -race -db=\"mysql\" -conn_str=\"root:@tcp(mysql)/xorm_test\" -coverprofile=coverage2-1.txt -covermode=atomic"
|
- make test-mysql
|
||||||
- "go test -v -race -db=\"mysql\" -conn_str=\"root:@tcp(mysql)/xorm_test\" -cache=true -coverprofile=coverage2-2.txt -covermode=atomic"
|
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
- name: test-mysql-utf8mb4
|
- name: test-mysql-cache
|
||||||
pull: default
|
|
||||||
image: golang:1.12
|
image: golang:1.12
|
||||||
depends_on:
|
depends_on:
|
||||||
- test-mysql
|
- test-mysql
|
||||||
environment:
|
environment:
|
||||||
GO111MODULE: "on"
|
GO111MODULE: "on"
|
||||||
GOPROXY: "https://goproxy.cn"
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_MYSQL_HOST: mysql
|
||||||
|
TEST_MYSQL_CHARSET: utf8
|
||||||
|
TEST_MYSQL_DBNAME: xorm_test
|
||||||
|
TEST_MYSQL_USERNAME: root
|
||||||
|
TEST_MYSQL_PASSWORD:
|
||||||
|
TEST_CACHE_ENABLE: true
|
||||||
commands:
|
commands:
|
||||||
- "go test -v -race -db=\"mysql\" -conn_str=\"root:@tcp(mysql)/xorm_test?charset=utf8mb4\" -coverprofile=coverage2.1-1.txt -covermode=atomic"
|
- make test-mysql
|
||||||
- "go test -v -race -db=\"mysql\" -conn_str=\"root:@tcp(mysql)/xorm_test?charset=utf8mb4\" -cache=true -coverprofile=coverage2.1-2.txt -covermode=atomic"
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
- name: test-mysql-utf8mb4
|
||||||
|
image: golang:1.12
|
||||||
|
depends_on:
|
||||||
|
- test-mysql-cache
|
||||||
|
environment:
|
||||||
|
GO111MODULE: "on"
|
||||||
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_MYSQL_HOST: mysql
|
||||||
|
TEST_MYSQL_CHARSET: utf8mb4
|
||||||
|
TEST_MYSQL_DBNAME: xorm_test
|
||||||
|
TEST_MYSQL_USERNAME: root
|
||||||
|
TEST_MYSQL_PASSWORD:
|
||||||
|
TEST_CACHE_ENABLE: false
|
||||||
|
commands:
|
||||||
|
- make test-mysql
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
- name: test-mysql-utf8mb4-cache
|
||||||
|
image: golang:1.12
|
||||||
|
depends_on:
|
||||||
|
- test-mysql-utf8mb4
|
||||||
|
environment:
|
||||||
|
GO111MODULE: "on"
|
||||||
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_MYSQL_HOST: mysql
|
||||||
|
TEST_MYSQL_CHARSET: utf8mb4
|
||||||
|
TEST_MYSQL_DBNAME: xorm_test
|
||||||
|
TEST_MYSQL_USERNAME: root
|
||||||
|
TEST_MYSQL_PASSWORD:
|
||||||
|
TEST_CACHE_ENABLE: true
|
||||||
|
commands:
|
||||||
|
- make test-mysql
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
@ -63,13 +124,37 @@ steps:
|
||||||
pull: default
|
pull: default
|
||||||
image: golang:1.12
|
image: golang:1.12
|
||||||
depends_on:
|
depends_on:
|
||||||
- test-mysql-utf8mb4
|
- test-mysql-utf8mb4-cache
|
||||||
environment:
|
environment:
|
||||||
GO111MODULE: "on"
|
GO111MODULE: "on"
|
||||||
GOPROXY: "https://goproxy.cn"
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_MYSQL_HOST: mysql:3306
|
||||||
|
TEST_MYSQL_DBNAME: xorm_test
|
||||||
|
TEST_MYSQL_USERNAME: root
|
||||||
|
TEST_MYSQL_PASSWORD:
|
||||||
|
TEST_CACHE_ENABLE: false
|
||||||
commands:
|
commands:
|
||||||
- "go test -v -race -db=\"mymysql\" -conn_str=\"tcp:mysql:3306*xorm_test/root/\" -coverprofile=coverage3-1.txt -covermode=atomic"
|
- make test-mymysql
|
||||||
- "go test -v -race -db=\"mymysql\" -conn_str=\"tcp:mysql:3306*xorm_test/root/\" -cache=true -coverprofile=coverage3-2.txt -covermode=atomic"
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
- name: test-mymysql-cache
|
||||||
|
pull: default
|
||||||
|
image: golang:1.12
|
||||||
|
depends_on:
|
||||||
|
- test-mymysql
|
||||||
|
environment:
|
||||||
|
GO111MODULE: "on"
|
||||||
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_MYSQL_HOST: mysql:3306
|
||||||
|
TEST_MYSQL_DBNAME: xorm_test
|
||||||
|
TEST_MYSQL_USERNAME: root
|
||||||
|
TEST_MYSQL_PASSWORD:
|
||||||
|
TEST_CACHE_ENABLE: true
|
||||||
|
commands:
|
||||||
|
- make test-mymysql
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
@ -81,9 +166,33 @@ steps:
|
||||||
environment:
|
environment:
|
||||||
GO111MODULE: "on"
|
GO111MODULE: "on"
|
||||||
GOPROXY: "https://goproxy.cn"
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_PGSQL_HOST: pgsql
|
||||||
|
TEST_PGSQL_DBNAME: xorm_test
|
||||||
|
TEST_PGSQL_USERNAME: postgres
|
||||||
|
TEST_PGSQL_PASSWORD: postgres
|
||||||
|
TEST_CACHE_ENABLE: false
|
||||||
commands:
|
commands:
|
||||||
- "go test -v -race -db=\"postgres\" -conn_str=\"postgres://postgres:postgres@pgsql/xorm_test?sslmode=disable\" -coverprofile=coverage4-1.txt -covermode=atomic"
|
- make test-postgres
|
||||||
- "go test -v -race -db=\"postgres\" -conn_str=\"postgres://postgres:postgres@pgsql/xorm_test?sslmode=disable\" -cache=true -coverprofile=coverage4-2.txt -covermode=atomic"
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
- name: test-postgres-cache
|
||||||
|
pull: default
|
||||||
|
image: golang:1.12
|
||||||
|
depends_on:
|
||||||
|
- test-postgres
|
||||||
|
environment:
|
||||||
|
GO111MODULE: "on"
|
||||||
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_PGSQL_HOST: pgsql
|
||||||
|
TEST_PGSQL_DBNAME: xorm_test
|
||||||
|
TEST_PGSQL_USERNAME: postgres
|
||||||
|
TEST_PGSQL_PASSWORD: postgres
|
||||||
|
TEST_CACHE_ENABLE: true
|
||||||
|
commands:
|
||||||
|
- make test-postgres
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
@ -95,9 +204,37 @@ steps:
|
||||||
environment:
|
environment:
|
||||||
GO111MODULE: "on"
|
GO111MODULE: "on"
|
||||||
GOPROXY: "https://goproxy.cn"
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_PGSQL_HOST: pgsql
|
||||||
|
TEST_PGSQL_SCHEMA: xorm
|
||||||
|
TEST_PGSQL_DBNAME: xorm_test
|
||||||
|
TEST_PGSQL_USERNAME: postgres
|
||||||
|
TEST_PGSQL_PASSWORD: postgres
|
||||||
|
TEST_CACHE_ENABLE: false
|
||||||
|
SCHEMA: xorm
|
||||||
commands:
|
commands:
|
||||||
- "go test -v -race -db=\"postgres\" -conn_str=\"postgres://postgres:postgres@pgsql/xorm_test?sslmode=disable\" -schema=xorm -coverprofile=coverage5-1.txt -covermode=atomic"
|
- make test-postgres
|
||||||
- "go test -v -race -db=\"postgres\" -conn_str=\"postgres://postgres:postgres@pgsql/xorm_test?sslmode=disable\" -schema=xorm -cache=true -coverprofile=coverage5-2.txt -covermode=atomic"
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
- name: test-postgres-schema-cache
|
||||||
|
pull: default
|
||||||
|
image: golang:1.12
|
||||||
|
depends_on:
|
||||||
|
- test-postgres-schema
|
||||||
|
environment:
|
||||||
|
GO111MODULE: "on"
|
||||||
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_PGSQL_HOST: pgsql
|
||||||
|
TEST_PGSQL_SCHEMA: xorm
|
||||||
|
TEST_PGSQL_DBNAME: xorm_test
|
||||||
|
TEST_PGSQL_USERNAME: postgres
|
||||||
|
TEST_PGSQL_PASSWORD: postgres
|
||||||
|
TEST_CACHE_ENABLE: true
|
||||||
|
SCHEMA: xorm
|
||||||
|
commands:
|
||||||
|
- make test-postgres
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
@ -109,9 +246,33 @@ steps:
|
||||||
environment:
|
environment:
|
||||||
GO111MODULE: "on"
|
GO111MODULE: "on"
|
||||||
GOPROXY: "https://goproxy.cn"
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_MSSQL_HOST: mssql
|
||||||
|
TEST_MSSQL_DBNAME: xorm_test
|
||||||
|
TEST_MSSQL_USERNAME: sa
|
||||||
|
TEST_MSSQL_PASSWORD: "yourStrong(!)Password"
|
||||||
|
TEST_CACHE_ENABLE: false
|
||||||
commands:
|
commands:
|
||||||
- "go test -v -race -db=\"mssql\" -conn_str=\"server=mssql;user id=sa;password=yourStrong(!)Password;database=xorm_test\" -coverprofile=coverage6-1.txt -covermode=atomic"
|
- make test-mssql
|
||||||
- "go test -v -race -db=\"mssql\" -conn_str=\"server=mssql;user id=sa;password=yourStrong(!)Password;database=xorm_test\" -cache=true -coverprofile=coverage6-2.txt -covermode=atomic"
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
- name: test-mssql-cache
|
||||||
|
pull: default
|
||||||
|
image: golang:1.12
|
||||||
|
depends_on:
|
||||||
|
- test-mssql
|
||||||
|
environment:
|
||||||
|
GO111MODULE: "on"
|
||||||
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_MSSQL_HOST: mssql
|
||||||
|
TEST_MSSQL_DBNAME: xorm_test
|
||||||
|
TEST_MSSQL_USERNAME: sa
|
||||||
|
TEST_MSSQL_PASSWORD: "yourStrong(!)Password"
|
||||||
|
TEST_CACHE_ENABLE: true
|
||||||
|
commands:
|
||||||
|
- make test-mssql
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
@ -123,9 +284,33 @@ steps:
|
||||||
environment:
|
environment:
|
||||||
GO111MODULE: "on"
|
GO111MODULE: "on"
|
||||||
GOPROXY: "https://goproxy.cn"
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_TIDB_HOST: "tidb:4000"
|
||||||
|
TEST_TIDB_DBNAME: xorm_test
|
||||||
|
TEST_TIDB_USERNAME: root
|
||||||
|
TEST_TIDB_PASSWORD:
|
||||||
|
TEST_CACHE_ENABLE: false
|
||||||
commands:
|
commands:
|
||||||
- "go test -v -race -db=\"mysql\" -conn_str=\"root:@tcp(tidb:4000)/xorm_test\" -ignore_select_update=true -coverprofile=coverage7-1.txt -covermode=atomic"
|
- make test-tidb
|
||||||
- "go test -v -race -db=\"mysql\" -conn_str=\"root:@tcp(tidb:4000)/xorm_test\" -ignore_select_update=true -cache=true -coverprofile=coverage7-2.txt -covermode=atomic"
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
- name: test-tidb-cache
|
||||||
|
pull: default
|
||||||
|
image: golang:1.12
|
||||||
|
depends_on:
|
||||||
|
- test-tidb
|
||||||
|
environment:
|
||||||
|
GO111MODULE: "on"
|
||||||
|
GOPROXY: "https://goproxy.cn"
|
||||||
|
TEST_TIDB_HOST: "tidb:4000"
|
||||||
|
TEST_TIDB_DBNAME: xorm_test
|
||||||
|
TEST_TIDB_USERNAME: root
|
||||||
|
TEST_TIDB_PASSWORD:
|
||||||
|
TEST_CACHE_ENABLE: true
|
||||||
|
commands:
|
||||||
|
- make test-tidb
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
@ -140,16 +325,23 @@ steps:
|
||||||
depends_on:
|
depends_on:
|
||||||
- test-vet
|
- test-vet
|
||||||
- test-sqlite
|
- test-sqlite
|
||||||
|
- test-sqlite-cache
|
||||||
- test-mysql
|
- test-mysql
|
||||||
|
- test-mysql-cache
|
||||||
- test-mysql-utf8mb4
|
- test-mysql-utf8mb4
|
||||||
|
- test-mysql-utf8mb4-cache
|
||||||
- test-mymysql
|
- test-mymysql
|
||||||
|
- test-mymysql-cache
|
||||||
- test-postgres
|
- test-postgres
|
||||||
|
- test-postgres-cache
|
||||||
- test-postgres-schema
|
- test-postgres-schema
|
||||||
|
- test-postgres-schema-cache
|
||||||
- test-mssql
|
- test-mssql
|
||||||
|
- test-mssql-cache
|
||||||
- test-tidb
|
- test-tidb
|
||||||
|
- test-tidb-cache
|
||||||
commands:
|
commands:
|
||||||
- go get github.com/wadey/gocovmerge
|
- make coverage
|
||||||
- gocovmerge coverage1-1.txt coverage1-2.txt coverage2-1.txt coverage2-2.txt coverage2.1-1.txt coverage2.1-2.txt coverage3-1.txt coverage3-2.txt coverage4-1.txt coverage4-2.txt coverage5-1.txt coverage5-2.txt coverage6-1.txt coverage6-2.txt coverage7-1.txt coverage7-2.txt > coverage.txt
|
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
ignoreGeneratedHeader = false
|
||||||
|
severity = "warning"
|
||||||
|
confidence = 0.8
|
||||||
|
errorCode = 1
|
||||||
|
warningCode = 1
|
||||||
|
|
||||||
|
[rule.blank-imports]
|
||||||
|
[rule.context-as-argument]
|
||||||
|
[rule.context-keys-type]
|
||||||
|
[rule.dot-imports]
|
||||||
|
[rule.error-return]
|
||||||
|
[rule.error-strings]
|
||||||
|
[rule.error-naming]
|
||||||
|
[rule.exported]
|
||||||
|
[rule.if-return]
|
||||||
|
[rule.increment-decrement]
|
||||||
|
[rule.var-naming]
|
||||||
|
[rule.var-declaration]
|
||||||
|
[rule.package-comments]
|
||||||
|
[rule.range]
|
||||||
|
[rule.receiver-naming]
|
||||||
|
[rule.time-naming]
|
||||||
|
[rule.unexported-return]
|
||||||
|
[rule.indent-error-flow]
|
||||||
|
[rule.errorf]
|
|
@ -0,0 +1,190 @@
|
||||||
|
IMPORT := xorm.io/xorm
|
||||||
|
export GO111MODULE=on
|
||||||
|
|
||||||
|
GO ?= go
|
||||||
|
GOFMT ?= gofmt -s
|
||||||
|
TAGS ?=
|
||||||
|
SED_INPLACE := sed -i
|
||||||
|
|
||||||
|
GOFILES := $(shell find . -name "*.go" -type f)
|
||||||
|
|
||||||
|
PACKAGES ?= $(shell GO111MODULE=on $(GO) list ./...)
|
||||||
|
|
||||||
|
TEST_MSSQL_HOST ?= mssql:1433
|
||||||
|
TEST_MSSQL_DBNAME ?= gitea
|
||||||
|
TEST_MSSQL_USERNAME ?= sa
|
||||||
|
TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1
|
||||||
|
|
||||||
|
TEST_MYSQL_HOST ?= mysql:3306
|
||||||
|
TEST_MYSQL_CHARSET ?= utf8
|
||||||
|
TEST_MYSQL_DBNAME ?= xorm_test
|
||||||
|
TEST_MYSQL_USERNAME ?= root
|
||||||
|
TEST_MYSQL_PASSWORD ?=
|
||||||
|
|
||||||
|
TEST_PGSQL_HOST ?= pgsql:5432
|
||||||
|
TEST_PGSQL_SCHEMA ?=
|
||||||
|
TEST_PGSQL_DBNAME ?= xorm_test
|
||||||
|
TEST_PGSQL_USERNAME ?= postgres
|
||||||
|
TEST_PGSQL_PASSWORD ?= mysecretpassword
|
||||||
|
|
||||||
|
TEST_TIDB_HOST ?= tidb:4000
|
||||||
|
TEST_TIDB_DBNAME ?= xorm_test
|
||||||
|
TEST_TIDB_USERNAME ?= root
|
||||||
|
TEST_TIDB_PASSWORD ?=
|
||||||
|
|
||||||
|
TEST_CACHE_ENABLE ?= false
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: build
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: go-check $(GO_SOURCES)
|
||||||
|
$(GO) build
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
$(GO) clean -i ./...
|
||||||
|
rm -rf *.sql *.log test.db *coverage.out coverage.all
|
||||||
|
|
||||||
|
.PHONY: coverage
|
||||||
|
coverage:
|
||||||
|
@hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
$(GO) get -u github.com/wadey/gocovmerge; \
|
||||||
|
fi
|
||||||
|
gocovmerge $(shell find . -type f -name "coverage.out") > coverage.all;\
|
||||||
|
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt:
|
||||||
|
$(GOFMT) -w $(GOFILES)
|
||||||
|
|
||||||
|
.PHONY: fmt-check
|
||||||
|
fmt-check:
|
||||||
|
# get all go files and run go fmt on them
|
||||||
|
@diff=$$($(GOFMT) -d $(GOFILES)); \
|
||||||
|
if [ -n "$$diff" ]; then \
|
||||||
|
echo "Please run 'make fmt' and commit the result:"; \
|
||||||
|
echo "$${diff}"; \
|
||||||
|
exit 1; \
|
||||||
|
fi;
|
||||||
|
|
||||||
|
.PHONY: go-check
|
||||||
|
go-check:
|
||||||
|
$(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell go version | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?\s' | tr '.' ' ');))
|
||||||
|
@if [ "$(GO_VERSION)" -lt "001011000" ]; then \
|
||||||
|
echo "Gitea requires Go 1.11.0 or greater to build. You can get it at https://golang.org/dl/"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
@echo "Make Routines:"
|
||||||
|
@echo " - equivalent to \"build\""
|
||||||
|
@echo " - build creates the entire project"
|
||||||
|
@echo " - clean delete integration files and build files but not css and js files"
|
||||||
|
@echo " - fmt format the code"
|
||||||
|
@echo " - lint run code linter revive"
|
||||||
|
@echo " - misspell check if a word is written wrong"
|
||||||
|
@echo " - test run default unit test"
|
||||||
|
@echo " - test-sqlite run unit test for sqlite"
|
||||||
|
@echo " - vet examines Go source code and reports suspicious constructs"
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint: revive
|
||||||
|
|
||||||
|
.PHONY: revive
|
||||||
|
revive:
|
||||||
|
@hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
$(GO) get -u github.com/mgechev/revive; \
|
||||||
|
fi
|
||||||
|
revive -config .revive.toml -exclude=./vendor/... ./... || exit 1
|
||||||
|
|
||||||
|
.PHONY: misspell
|
||||||
|
misspell:
|
||||||
|
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
||||||
|
fi
|
||||||
|
misspell -w -i unknwon $(GOFILES)
|
||||||
|
|
||||||
|
.PHONY: misspell-check
|
||||||
|
misspell-check:
|
||||||
|
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
||||||
|
fi
|
||||||
|
misspell -error -i unknwon,destory $(GOFILES)
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: test-sqlite
|
||||||
|
|
||||||
|
.PNONY: test-mssql
|
||||||
|
test-mssql: go-check
|
||||||
|
$(GO) test -race -db=mssql -cache=$(TEST_CACHE_ENABLE) \
|
||||||
|
-conn_str="server=$(TEST_MSSQL_HOST);user id=$(TEST_MSSQL_USERNAME);password=$(TEST_MSSQL_PASSWORD);database=$(TEST_MSSQL_DBNAME)" \
|
||||||
|
-coverprofile=mssql.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PNONY: test-mssql\#%
|
||||||
|
test-mssql\#%: go-check
|
||||||
|
$(GO) test -race -run $* -db=mssql -cache=$(TEST_CACHE_ENABLE) \
|
||||||
|
-conn_str="server=$(TEST_MSSQL_HOST);user id=$(TEST_MSSQL_USERNAME);password=$(TEST_MSSQL_PASSWORD);database=$(TEST_MSSQL_DBNAME)" \
|
||||||
|
-coverprofile=mssql.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PNONY: test-mymysql
|
||||||
|
test-mymysql: go-check
|
||||||
|
$(GO) test -race -db=mymysql -cache=$(TEST_CACHE_ENABLE) \
|
||||||
|
-conn_str="tcp:$(TEST_MYSQL_HOST)*$(TEST_MYSQL_DBNAME)/$(TEST_MYSQL_USERNAME)/$(TEST_MYSQL_PASSWORD)" \
|
||||||
|
-coverprofile=mymysql.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PNONY: test-mymysql\#%
|
||||||
|
test-mymysql\#%: go-check
|
||||||
|
$(GO) test -race -run $* -db=mymysql -cache=$(TEST_CACHE_ENABLE) \
|
||||||
|
-conn_str="tcp:$(TEST_MYSQL_HOST)*$(TEST_MYSQL_DBNAME)/$(TEST_MYSQL_USERNAME)/$(TEST_MYSQL_PASSWORD)" \
|
||||||
|
-coverprofile=mymysql.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PNONY: test-mysql
|
||||||
|
test-mysql: go-check
|
||||||
|
$(GO) test -race -db=mysql -cache=$(TEST_CACHE_ENABLE) \
|
||||||
|
-conn_str="$(TEST_MYSQL_USERNAME):$(TEST_MYSQL_PASSWORD)@tcp($(TEST_MYSQL_HOST))/$(TEST_MYSQL_DBNAME)?charset=$(TEST_MYSQL_CHARSET)" \
|
||||||
|
-coverprofile=mysql.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PHONY: test-mysql\#%
|
||||||
|
test-mysql\#%: go-check
|
||||||
|
$(GO) test -race -run $* -db=mysql -cache=$(TEST_CACHE_ENABLE) \
|
||||||
|
-conn_str="$(TEST_MYSQL_USERNAME):$(TEST_MYSQL_PASSWORD)@tcp($(TEST_MYSQL_HOST))/$(TEST_MYSQL_DBNAME)?charset=$(TEST_MYSQL_CHARSET)" \
|
||||||
|
-coverprofile=mysql.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PNONY: test-postgres
|
||||||
|
test-postgres: go-check
|
||||||
|
$(GO) test -race -db=postgres -schema='$(TEST_PGSQL_SCHEMA)' -cache=$(TEST_CACHE_ENABLE) \
|
||||||
|
-conn_str="postgres://$(TEST_PGSQL_USERNAME):$(TEST_PGSQL_PASSWORD)@$(TEST_PGSQL_HOST)/$(TEST_PGSQL_DBNAME)?sslmode=disable" \
|
||||||
|
-coverprofile=postgres.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PHONY: test-postgres\#%
|
||||||
|
test-postgres\#%: go-check
|
||||||
|
$(GO) test -race -run $* -db=postgres -schema='$(TEST_PGSQL_SCHEMA)' -cache=$(TEST_CACHE_ENABLE) \
|
||||||
|
-conn_str="postgres://$(TEST_PGSQL_USERNAME):$(TEST_PGSQL_PASSWORD)@$(TEST_PGSQL_HOST)/$(TEST_PGSQL_DBNAME)?sslmode=disable" \
|
||||||
|
-coverprofile=postgres.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PHONY: test-sqlite
|
||||||
|
test-sqlite: go-check
|
||||||
|
$(GO) test -race -cache=$(TEST_CACHE_ENABLE) -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc" \
|
||||||
|
-coverprofile=sqlite.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PHONY: test-sqlite\#%
|
||||||
|
test-sqlite\#%: go-check
|
||||||
|
$(GO) test -race -run $* -cache=$(TEST_CACHE_ENABLE) -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc" \
|
||||||
|
-coverprofile=sqlite.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PNONY: test-tidb
|
||||||
|
test-tidb: go-check
|
||||||
|
$(GO) test -race -db=mysql -cache=$(TEST_CACHE_ENABLE) -ignore_select_update=true \
|
||||||
|
-conn_str="$(TEST_TIDB_USERNAME):$(TEST_TIDB_PASSWORD)@tcp($(TEST_TIDB_HOST))/$(TEST_TIDB_DBNAME)" \
|
||||||
|
-coverprofile=tidb.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PHONY: test-tidb\#%
|
||||||
|
test-tidb\#%: go-check
|
||||||
|
$(GO) test -race -run $* -db=mysql -cache=$(TEST_CACHE_ENABLE) -ignore_select_update=true \
|
||||||
|
-conn_str="$(TEST_TIDB_USERNAME):$(TEST_TIDB_PASSWORD)@tcp($(TEST_TIDB_HOST))/$(TEST_TIDB_DBNAME)" \
|
||||||
|
-coverprofile=tidb.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
.PHONY: vet
|
||||||
|
vet:
|
||||||
|
$(GO) vet $(PACKAGES)
|
|
@ -7,8 +7,8 @@ package xorm
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"xorm.io/core"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"xorm.io/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLRUCache(t *testing.T) {
|
func TestLRUCache(t *testing.T) {
|
||||||
|
|
|
@ -25,12 +25,12 @@ func TestMemoryStore(t *testing.T) {
|
||||||
assert.EqualValues(t, v, val)
|
assert.EqualValues(t, v, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, _ := range kvs {
|
for k := range kvs {
|
||||||
err := store.Del(k)
|
err := store.Del(k)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, _ := range kvs {
|
for k := range kvs {
|
||||||
_, err := store.Get(k)
|
_, err := store.Get(k)
|
||||||
assert.EqualValues(t, ErrNotExist, err)
|
assert.EqualValues(t, ErrNotExist, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -838,7 +838,7 @@ func (engine *Engine) Having(conditions string) *Session {
|
||||||
return session.Having(conditions)
|
return session.Having(conditions)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnMapType removes the datbase mapper of a type
|
// UnMapType removes the database mapper of a type
|
||||||
func (engine *Engine) UnMapType(t reflect.Type) {
|
func (engine *Engine) UnMapType(t reflect.Type) {
|
||||||
engine.mutex.Lock()
|
engine.mutex.Lock()
|
||||||
defer engine.mutex.Unlock()
|
defer engine.mutex.Unlock()
|
||||||
|
@ -987,11 +987,11 @@ func (engine *Engine) mapType(v reflect.Value) (*core.Table, error) {
|
||||||
|
|
||||||
pStart := strings.Index(k, "(")
|
pStart := strings.Index(k, "(")
|
||||||
if pStart == 0 {
|
if pStart == 0 {
|
||||||
return nil, errors.New("( could not be the first charactor")
|
return nil, errors.New("( could not be the first character")
|
||||||
}
|
}
|
||||||
if pStart > -1 {
|
if pStart > -1 {
|
||||||
if !strings.HasSuffix(k, ")") {
|
if !strings.HasSuffix(k, ")") {
|
||||||
return nil, fmt.Errorf("field %s tag %s cannot match ) charactor", col.FieldName, key)
|
return nil, fmt.Errorf("field %s tag %s cannot match ) character", col.FieldName, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.tagName = k[:pStart]
|
ctx.tagName = k[:pStart]
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User describes a user
|
// User describes a user
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"xorm.io/xorm"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User describes a user
|
// User describes a user
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Status describes a status
|
// Status describes a status
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User describes a user
|
// User describes a user
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User describes a user
|
// User describes a user
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"xorm.io/xorm"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User describes a user
|
// User describes a user
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User describes a user
|
// User describes a user
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"xorm.io/xorm"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User describes a user
|
// User describes a user
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"xorm.io/xorm"
|
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SyncUser2 describes a user
|
// SyncUser2 describes a user
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Person struct {
|
type Person struct {
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"xorm.io/builder"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"xorm.io/builder"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBuilder(t *testing.T) {
|
func TestBuilder(t *testing.T) {
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/core"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"xorm.io/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDelete(t *testing.T) {
|
func TestDelete(t *testing.T) {
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/core"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"xorm.io/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestJoinLimit(t *testing.T) {
|
func TestJoinLimit(t *testing.T) {
|
||||||
|
|
|
@ -553,10 +553,10 @@ func TestInsertMulti2(t *testing.T) {
|
||||||
assert.EqualValues(t, len(users), cnt)
|
assert.EqualValues(t, len(users), cnt)
|
||||||
|
|
||||||
users2 := []*Userinfo{
|
users2 := []*Userinfo{
|
||||||
&Userinfo{Username: "1xlw", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
{Username: "1xlw", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
||||||
&Userinfo{Username: "1xlw2", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
{Username: "1xlw2", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
||||||
&Userinfo{Username: "1xlw11", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
{Username: "1xlw11", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
||||||
&Userinfo{Username: "1xlw22", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
{Username: "1xlw22", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt, err = testEngine.Insert(&users2)
|
cnt, err = testEngine.Insert(&users2)
|
||||||
|
@ -646,10 +646,10 @@ func TestInsertMulti3(t *testing.T) {
|
||||||
assert.EqualValues(t, len(users), cnt)
|
assert.EqualValues(t, len(users), cnt)
|
||||||
|
|
||||||
users2 := []*MyUserinfo{
|
users2 := []*MyUserinfo{
|
||||||
&MyUserinfo{Username: "1xlw", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
{Username: "1xlw", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
||||||
&MyUserinfo{Username: "1xlw2", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
{Username: "1xlw2", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
||||||
&MyUserinfo{Username: "1xlw11", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
{Username: "1xlw11", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
||||||
&MyUserinfo{Username: "1xlw22", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
{Username: "1xlw22", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt, err = testEngine.Insert(&users2)
|
cnt, err = testEngine.Insert(&users2)
|
||||||
|
@ -691,10 +691,10 @@ func TestInsertMulti4(t *testing.T) {
|
||||||
assert.EqualValues(t, len(users), cnt)
|
assert.EqualValues(t, len(users), cnt)
|
||||||
|
|
||||||
users2 := []*MyUserinfo2{
|
users2 := []*MyUserinfo2{
|
||||||
&MyUserinfo2{Username: "1xlw", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
{Username: "1xlw", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
||||||
&MyUserinfo2{Username: "1xlw2", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
{Username: "1xlw2", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
||||||
&MyUserinfo2{Username: "1xlw11", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
{Username: "1xlw11", Departname: "dev", Alias: "lunny2", Created: time.Now()},
|
||||||
&MyUserinfo2{Username: "1xlw22", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
{Username: "1xlw22", Departname: "dev", Alias: "lunny3", Created: time.Now()},
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt, err = testEngine.Insert(&users2)
|
cnt, err = testEngine.Insert(&users2)
|
||||||
|
@ -1083,7 +1083,7 @@ func TestInsertTwice(t *testing.T) {
|
||||||
|
|
||||||
var sliceA []InsertStructA // sliceA is empty
|
var sliceA []InsertStructA // sliceA is empty
|
||||||
sliceB := []InsertStructB{
|
sliceB := []InsertStructB{
|
||||||
InsertStructB{
|
{
|
||||||
FieldB: 1,
|
FieldB: 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/core"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"xorm.io/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IntId struct {
|
type IntId struct {
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"xorm.io/builder"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"xorm.io/builder"
|
||||||
)
|
)
|
||||||
|
|
||||||
func isFloatEq(i, j float64, precision int) bool {
|
func isFloatEq(i, j float64, precision int) bool {
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/core"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"xorm.io/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestTransaction(t *testing.T) {
|
func TestTransaction(t *testing.T) {
|
||||||
|
|
|
@ -407,7 +407,7 @@ func TestUpdate1(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if cnt != 1 {
|
if cnt != 1 {
|
||||||
err = errors.New(fmt.Sprintf("insert not returned 1 but %d", cnt))
|
err = fmt.Errorf("insert not returned 1 but %d", cnt)
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -745,7 +745,7 @@ func TestUpdateSameMapper(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
if cnt != 1 {
|
if cnt != 1 {
|
||||||
err = errors.New(fmt.Sprintf("insert not returned 1 but %d", cnt))
|
err = fmt.Errorf("insert not returned 1 but %d", cnt)
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,7 @@ func TestUseBool(t *testing.T) {
|
||||||
var fNumber int64
|
var fNumber int64
|
||||||
for _, u := range users {
|
for _, u := range users {
|
||||||
if u.IsMan == false {
|
if u.IsMan == false {
|
||||||
fNumber += 1
|
fNumber++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
tag.go
2
tag.go
|
@ -81,7 +81,7 @@ func OnlyToDBTagHandler(ctx *tagContext) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PKTagHandler decribes primary key tag handler
|
// PKTagHandler describes primary key tag handler
|
||||||
func PKTagHandler(ctx *tagContext) error {
|
func PKTagHandler(ctx *tagContext) error {
|
||||||
ctx.col.IsPrimaryKey = true
|
ctx.col.IsPrimaryKey = true
|
||||||
ctx.col.Nullable = false
|
ctx.col.Nullable = false
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/core"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"xorm.io/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type tempUser struct {
|
type tempUser struct {
|
||||||
|
|
|
@ -56,7 +56,7 @@ func TestVersion1(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !has {
|
if !has {
|
||||||
t.Error(errors.New(fmt.Sprintf("no version id is %v", ver.Id)))
|
t.Error(fmt.Errorf("no version id is %v", ver.Id))
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Println(newVer)
|
fmt.Println(newVer)
|
||||||
|
@ -170,7 +170,7 @@ func TestVersion3(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !has {
|
if !has {
|
||||||
t.Error(errors.New(fmt.Sprintf("no version id is %v", ver.Id)))
|
t.Error(fmt.Errorf("no version id is %v", ver.Id))
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Println(newVer)
|
fmt.Println(newVer)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
go test -db=mssql -conn_str="server=localhost;user id=sa;password=yourStrong(!)Password;database=xorm_test"
|
|
|
@ -1 +0,0 @@
|
||||||
go test -db=mssql -conn_str="server=192.168.1.58;user id=sa;password=123456;database=xorm_test" -cache=true
|
|
|
@ -1 +0,0 @@
|
||||||
go test -db=mymysql -conn_str="xorm_test/root/"
|
|
|
@ -1 +0,0 @@
|
||||||
go test -db=mymysql -conn_str="xorm_test/root/" -cache=true
|
|
|
@ -1 +0,0 @@
|
||||||
go test -db=mysql -conn_str="root:@/xorm_test"
|
|
|
@ -1 +0,0 @@
|
||||||
go test -db=mysql -conn_str="root:@/xorm_test" -cache=true
|
|
|
@ -1 +0,0 @@
|
||||||
go test -db=postgres -conn_str="dbname=xorm_test sslmode=disable"
|
|
|
@ -1 +0,0 @@
|
||||||
go test -db=postgres -conn_str="dbname=xorm_test sslmode=disable" -cache=true
|
|
|
@ -1 +0,0 @@
|
||||||
go test -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc"
|
|
|
@ -1 +0,0 @@
|
||||||
go test -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc" -cache=true
|
|
|
@ -1 +0,0 @@
|
||||||
go test -db=mysql -conn_str="root:@tcp(localhost:4000)/xorm_test" -ignore_select_update=true
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"xorm.io/core"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"xorm.io/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestArrayField(t *testing.T) {
|
func TestArrayField(t *testing.T) {
|
||||||
|
@ -268,11 +268,11 @@ type Status struct {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ core.Conversion = &Status{}
|
_ core.Conversion = &Status{}
|
||||||
Registed Status = Status{"Registed", "white"}
|
Registered Status = Status{"Registered", "white"}
|
||||||
Approved Status = Status{"Approved", "green"}
|
Approved Status = Status{"Approved", "green"}
|
||||||
Removed Status = Status{"Removed", "red"}
|
Removed Status = Status{"Removed", "red"}
|
||||||
Statuses map[string]Status = map[string]Status{
|
Statuses map[string]Status = map[string]Status{
|
||||||
Registed.Name: Registed,
|
Registered.Name: Registered,
|
||||||
Approved.Name: Approved,
|
Approved.Name: Approved,
|
||||||
Removed.Name: Removed,
|
Removed.Name: Removed,
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ func TestCustomType2(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt, err := session.Insert(&UserCus{1, "xlw", Registed})
|
cnt, err := session.Insert(&UserCus{1, "xlw", Registered})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 1, cnt)
|
assert.EqualValues(t, 1, cnt)
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ func TestCustomType2(t *testing.T) {
|
||||||
fmt.Println(user)
|
fmt.Println(user)
|
||||||
|
|
||||||
users := make([]UserCus, 0)
|
users := make([]UserCus, 0)
|
||||||
err = testEngine.Where("`"+testEngine.GetColumnMapper().Obj2Table("Status")+"` = ?", "Registed").Find(&users)
|
err = testEngine.Where("`"+testEngine.GetColumnMapper().Obj2Table("Status")+"` = ?", "Registered").Find(&users)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 1, len(users))
|
assert.EqualValues(t, 1, len(users))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue