From 89413a5358f08bd50d63697a9d602698546b4306 Mon Sep 17 00:00:00 2001 From: Anker Jam Date: Wed, 27 Jan 2021 22:09:41 +0800 Subject: [PATCH 1/8] wrap ormer into QueryExecutor --- client/orm/types.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/orm/types.go b/client/orm/types.go index cb735ac8..be402971 100644 --- a/client/orm/types.go +++ b/client/orm/types.go @@ -211,19 +211,25 @@ type DriverGetter interface { Driver() Driver } + type ormer interface { DQL DML DriverGetter } -type Ormer interface { +//QueryExecutor wrapping for ormer +type QueryExecutor interface { ormer +} + +type Ormer interface { + QueryExecutor TxBeginner } type TxOrmer interface { - ormer + QueryExecutor TxCommitter } From 8404edee529b39a5cbcbb7b61344a0304a241018 Mon Sep 17 00:00:00 2001 From: Anker Jam Date: Wed, 27 Jan 2021 22:28:11 +0800 Subject: [PATCH 2/8] add changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a259efc..deb5c76c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,4 +3,5 @@ - Remove `duration` from prometheus labels. [4391](https://github.com/beego/beego/pull/4391) - Fix `unknown escape sequence` in generated code. [4385](https://github.com/beego/beego/pull/4385) - Using fixed name `commentRouter.go` as generated file name. [4385](https://github.com/beego/beego/pull/4385) -- Fix 4383: ORM Adapter produces panic when using orm.RegisterModelWithPrefix. [4386](https://github.com/beego/beego/pull/4386) \ No newline at end of file +- Fix 4383: ORM Adapter produces panic when using orm.RegisterModelWithPrefix. [4386](https://github.com/beego/beego/pull/4386) +- Fix 4451: support QueryExecutor interface. [4461](https://github.com/beego/beego/pull/4461) From a4d301fe8d0b20ce34a0a87e9b753c0a7627c8e7 Mon Sep 17 00:00:00 2001 From: jianzhiyao Date: Thu, 28 Jan 2021 15:28:07 +0800 Subject: [PATCH 3/8] remove golint in travis --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 252ec905..8f6e0399 100644 --- a/.travis.yml +++ b/.travis.yml @@ -79,7 +79,6 @@ install: - go get -u honnef.co/go/tools/cmd/staticcheck - go get -u github.com/mdempsky/unconvert - go get -u github.com/gordonklaus/ineffassign - - go get -u golang.org/x/lint/golint - go get -u github.com/go-redis/redis before_script: @@ -89,7 +88,6 @@ before_script: - sh -c "if [ '$ORM_DRIVER' = 'postgres' ]; then psql -c 'create database orm_test;' -U postgres; fi" - sh -c "if [ '$ORM_DRIVER' = 'mysql' ]; then mysql -u root -e 'create database orm_test;'; fi" - sh -c "if [ '$ORM_DRIVER' = 'sqlite' ]; then touch $TRAVIS_BUILD_DIR/orm_test.db; fi" - - sh -c "go get github.com/golang/lint/golint; golint ./...;" - sh -c "go list ./... | grep -v vendor | xargs go vet -v" - mkdir -p res/var - ./ssdb/ssdb-server ./ssdb/ssdb.conf -d @@ -104,6 +102,5 @@ script: - unconvert $(go list ./... | grep -v /vendor/) - ineffassign . - find . ! \( -path './vendor' -prune \) -type f -name '*.go' -print0 | xargs -0 gofmt -l -s - - golint ./... addons: postgresql: "9.6" From 7e3703d83ed658df32a4720d621e5593c2eb5357 Mon Sep 17 00:00:00 2001 From: jianzhiyao Date: Thu, 28 Jan 2021 16:13:55 +0800 Subject: [PATCH 4/8] fix reportcard in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6450e183..93288ac9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Beego [![Build Status](https://travis-ci.org/astaxie/beego.svg?branch=master)](https://travis-ci.org/astaxie/beego) [![GoDoc](http://godoc.org/github.com/beego/beego/v2?status.svg)](http://godoc.org/github.com/beego/beego/v2) [![Foundation](https://img.shields.io/badge/Golang-Foundation-green.svg)](http://golangfoundation.org) [![Go Report Card](https://goreportcard.com/badge/github.com/beego/beego/v2)](https://goreportcard.com/report/github.com/beego/beego/v2) +# Beego [![Build Status](https://travis-ci.org/astaxie/beego.svg?branch=master)](https://travis-ci.org/astaxie/beego) [![GoDoc](http://godoc.org/github.com/beego/beego/v2?status.svg)](http://godoc.org/github.com/beego/beego/v2) [![Foundation](https://img.shields.io/badge/Golang-Foundation-green.svg)](http://golangfoundation.org) [![Go Report Card](https://goreportcard.com/badge/github.com/beego/beego)](https://goreportcard.com/report/github.com/beego/beego) Beego is used for rapid development of enterprise application in Go, including RESTful APIs, web apps and backend services. From 4dca2287ff41f58d3799009c6f3a9f9f6e300a96 Mon Sep 17 00:00:00 2001 From: jianzhiyao Date: Thu, 28 Jan 2021 17:10:35 +0800 Subject: [PATCH 5/8] add some testing scripts --- scripts/adapter.sh | 13 ++++++++ scripts/prepare_etcd.sh | 8 +++++ scripts/test.sh | 17 ++++++++++ scripts/test_docker_compose.yaml | 55 ++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 scripts/adapter.sh create mode 100644 scripts/prepare_etcd.sh create mode 100644 scripts/test.sh create mode 100644 scripts/test_docker_compose.yaml diff --git a/scripts/adapter.sh b/scripts/adapter.sh new file mode 100644 index 00000000..e5d2d0a4 --- /dev/null +++ b/scripts/adapter.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# using pkg/adapter. Usually you want to migrate to V2 smoothly, you could running this script + +find ./ -name '*.go' -type f -exec sed -i '' -e 's/github.com\/astaxie\/beego/github.com\/astaxie\/beego\/pkg\/adapter/g' {} \; +find ./ -name '*.go' -type f -exec sed -i '' -e 's/"github.com\/astaxie\/beego\/pkg\/adapter"/beego "github.com\/astaxie\/beego\/pkg\/adapter"/g' {} \; + +update rrp_flow set status = 4 where flow_id in (5623711176,5629411891) + +select * from rrp_flow where flow_id in (5623711176,5629411891) and status = 5 + +update rrp_flow set status = 5 where flow_id in (5623711176,5629411891) + diff --git a/scripts/prepare_etcd.sh b/scripts/prepare_etcd.sh new file mode 100644 index 00000000..d34c05a3 --- /dev/null +++ b/scripts/prepare_etcd.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +etcdctl put current.float 1.23 +etcdctl put current.bool true +etcdctl put current.int 11 +etcdctl put current.string hello +etcdctl put current.serialize.name test +etcdctl put sub.sub.key1 sub.sub.key \ No newline at end of file diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100644 index 00000000..977055a3 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +docker-compose -f "$(pwd)/scripts/test_docker_compose.yaml" up -d + +export ORM_DRIVER=mysql +export TZ=UTC +export ORM_SOURCE="beego:test@tcp(localhost:13306)/orm_test?charset=utf8" + +# wait for services in images ready +sleep 5 + +go test "$(pwd)/..." + +# clear all container +docker-compose -f "$(pwd)/scripts/test_docker_compose.yaml" down + + diff --git a/scripts/test_docker_compose.yaml b/scripts/test_docker_compose.yaml new file mode 100644 index 00000000..f22b6deb --- /dev/null +++ b/scripts/test_docker_compose.yaml @@ -0,0 +1,55 @@ +version: "3.8" +services: + redis: + container_name: "beego-redis" + image: redis + environment: + - ALLOW_EMPTY_PASSWORD=yes + ports: + - "6379:6379" + + mysql: + container_name: "beego-mysql" + image: mysql:5.7.30 + ports: + - "13306:3306" + environment: + - MYSQL_ROOT_PASSWORD=1q2w3e + - MYSQL_DATABASE=orm_test + - MYSQL_USER=beego + - MYSQL_PASSWORD=test + + postgresql: + container_name: "beego-postgresql" + image: bitnami/postgresql:latest + ports: + - "5432:5432" + environment: + - ALLOW_EMPTY_PASSWORD=yes + ssdb: + container_name: "beego-ssdb" + image: wendal/ssdb + ports: + - "8888:8888" + memcache: + container_name: "beego-memcache" + image: memcached + ports: + - "11211:11211" + etcd: + command: > + sh -c " + etcdctl put current.float 1.23 + && etcdctl put current.bool true + && etcdctl put current.int 11 + && etcdctl put current.string hello + && etcdctl put current.serialize.name test + " + container_name: "beego-etcd" + environment: + - ALLOW_NONE_AUTHENTICATION=yes +# - ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379 + image: bitnami/etcd + ports: + - "2379:2379" + - "2380:2380" \ No newline at end of file From 5a642cd92dfc5848489059ad2d70a21a9bd2ddf4 Mon Sep 17 00:00:00 2001 From: jianzhiyao Date: Thu, 28 Jan 2021 17:12:04 +0800 Subject: [PATCH 6/8] update contributing.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2f9189e2..0db745cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,7 +36,7 @@ We provide docker compose file to start all middlewares. You can run: ```shell script -docker-compose -f scripts/test_docker_compose.yml up -d +docker-compose -f scripts/test_docker_compose.yaml up -d ``` Unit tests read addresses from environment, here is an example: From 468f075a708abaad13981f26a8ea7497ea788eb1 Mon Sep 17 00:00:00 2001 From: jianzhiyao Date: Thu, 28 Jan 2021 17:30:06 +0800 Subject: [PATCH 7/8] fix readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 93288ac9..66abc883 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Beego [![Build Status](https://travis-ci.org/astaxie/beego.svg?branch=master)](https://travis-ci.org/astaxie/beego) [![GoDoc](http://godoc.org/github.com/beego/beego/v2?status.svg)](http://godoc.org/github.com/beego/beego/v2) [![Foundation](https://img.shields.io/badge/Golang-Foundation-green.svg)](http://golangfoundation.org) [![Go Report Card](https://goreportcard.com/badge/github.com/beego/beego)](https://goreportcard.com/report/github.com/beego/beego) +# Beego [![Build Status](https://travis-ci.org/beego/beego.svg?branch=master)](https://travis-ci.org/beego/beego) [![GoDoc](http://godoc.org/github.com/beego/beego?status.svg)](http://godoc.org/github.com/beego/beego) [![Foundation](https://img.shields.io/badge/Golang-Foundation-green.svg)](http://golangfoundation.org) [![Go Report Card](https://goreportcard.com/badge/github.com/beego/beego)](https://goreportcard.com/report/github.com/beego/beego) Beego is used for rapid development of enterprise application in Go, including RESTful APIs, web apps and backend services. From 0e8c4fc9e254cd63c8a73913ee7595a55c0d7f20 Mon Sep 17 00:00:00 2001 From: Anker Jam Date: Thu, 28 Jan 2021 22:28:25 +0800 Subject: [PATCH 8/8] remove useless script --- CHANGELOG.md | 1 + scripts/adapter.sh | 13 ------------- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 scripts/adapter.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index e758cec4..14c6793f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,3 +19,4 @@ - Fix 4456: Fix router method expression [4456](https://github.com/beego/beego/pull/4456) - Remove some `go get` lines in `.travis.yml` file [4469](https://github.com/beego/beego/pull/4469) - Fix 4451: support QueryExecutor interface. [4461](https://github.com/beego/beego/pull/4461) +- Add some testing scripts [4461](https://github.com/beego/beego/pull/4461) diff --git a/scripts/adapter.sh b/scripts/adapter.sh deleted file mode 100644 index e5d2d0a4..00000000 --- a/scripts/adapter.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# using pkg/adapter. Usually you want to migrate to V2 smoothly, you could running this script - -find ./ -name '*.go' -type f -exec sed -i '' -e 's/github.com\/astaxie\/beego/github.com\/astaxie\/beego\/pkg\/adapter/g' {} \; -find ./ -name '*.go' -type f -exec sed -i '' -e 's/"github.com\/astaxie\/beego\/pkg\/adapter"/beego "github.com\/astaxie\/beego\/pkg\/adapter"/g' {} \; - -update rrp_flow set status = 4 where flow_id in (5623711176,5629411891) - -select * from rrp_flow where flow_id in (5623711176,5629411891) and status = 5 - -update rrp_flow set status = 5 where flow_id in (5623711176,5629411891) -