Refactor db package and remove unnecessary DumpTables (#32930)

This commit is contained in:
wxiaoguang 2024-12-21 00:11:38 +08:00 committed by GitHub
parent 7580bd98c1
commit 1c9b022c4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 247 additions and 221 deletions

View file

@ -13,6 +13,8 @@ import (
"code.gitea.io/gitea/modules/json"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"xorm.io/xorm"
"xorm.io/xorm/schemas"
)
@ -54,7 +56,8 @@ func TestDumpAuthSource(t *testing.T) {
sb := new(strings.Builder)
db.DumpTables([]*schemas.Table{authSourceSchema}, sb)
// TODO: this test is quite hacky, it should use a low-level "select" (without model processors) but not a database dump
engine := db.GetEngine(db.DefaultContext).(*xorm.Engine)
require.NoError(t, engine.DumpTables([]*schemas.Table{authSourceSchema}, sb))
assert.Contains(t, sb.String(), `"Provider":"ConvertibleSourceName"`)
}