Skip to content

Commit

Permalink
Upgrade xorm to v1.2.2 (#16663) & Add test to ensure that dumping of …
Browse files Browse the repository at this point in the history
…login sources remains correct (#16847) (#16848)

* Upgrade xorm to v1.2.2 (#16663)

Backport #16663

Fix #16683

* Add test to ensure that dumping of login sources remains correct (#16847)

#16831 has occurred because of a missed regression. This PR adds a simple test to
try to prevent this occuring again.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
  • Loading branch information
zeripath and lunny authored Aug 28, 2021
1 parent 0c7927f commit 1790f01
Show file tree
Hide file tree
Showing 135 changed files with 42,891 additions and 5,404 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ require (
github.com/markbates/goth v1.68.0
github.com/mattn/go-isatty v0.0.13
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-sqlite3 v1.14.7
github.com/mattn/go-sqlite3 v1.14.8
github.com/mholt/archiver/v3 v3.5.0
github.com/microcosm-cc/bluemonday v1.0.15
github.com/miekg/dns v1.1.43 // indirect
Expand Down Expand Up @@ -139,7 +139,7 @@ require (
mvdan.cc/xurls/v2 v2.2.0
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
xorm.io/builder v0.3.9
xorm.io/xorm v1.1.2
xorm.io/xorm v1.2.2
)

replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1
Expand Down
202 changes: 175 additions & 27 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Engine interface {
Table(tableNameOrBean interface{}) *xorm.Session
Count(...interface{}) (int64, error)
Decr(column string, arg ...interface{}) *xorm.Session
Delete(interface{}) (int64, error)
Delete(...interface{}) (int64, error)
Exec(...interface{}) (sql.Result, error)
Find(interface{}, ...interface{}) error
Get(interface{}) (bool, error)
Expand Down
26 changes: 26 additions & 0 deletions models/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"

"code.gitea.io/gitea/modules/auth/oauth2"
"code.gitea.io/gitea/modules/setting"
"xorm.io/xorm/schemas"

"github.com/stretchr/testify/assert"
)
Expand All @@ -32,3 +35,26 @@ func TestDumpDatabase(t *testing.T) {
assert.NoError(t, DumpDatabase(filepath.Join(dir, dbType+".sql"), dbType))
}
}

func TestDumpLoginSource(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())

loginSourceSchema, err := x.TableInfo(new(LoginSource))
assert.NoError(t, err)

CreateLoginSource(&LoginSource{
Type: LoginOAuth2,
Name: "TestSource",
IsActived: false,
Cfg: &OAuth2Config{
Provider: "TestSourceProvider",
CustomURLMapping: &oauth2.CustomURLMapping{},
},
})

sb := new(strings.Builder)

x.DumpTables([]*schemas.Table{loginSourceSchema}, sb)

assert.Contains(t, sb.String(), `"Provider":"TestSourceProvider"`)
}
32 changes: 32 additions & 0 deletions vendor/github.com/goccy/go-json/.codecov.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/goccy/go-json/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions vendor/github.com/goccy/go-json/.golangci.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1790f01

Please sign in to comment.