Skip to content

Commit 12d1e36

Browse files
committed
Add test to ensure that dumping of login sources remains correct (go-gitea#16847)
go-gitea#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 <[email protected]>
1 parent ac212b0 commit 12d1e36

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

models/models_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import (
88
"io/ioutil"
99
"os"
1010
"path/filepath"
11+
"strings"
1112
"testing"
1213

14+
"code.gitea.io/gitea/modules/auth/oauth2"
1315
"code.gitea.io/gitea/modules/setting"
16+
"xorm.io/xorm/schemas"
1417

1518
"github.com/stretchr/testify/assert"
1619
)
@@ -32,3 +35,26 @@ func TestDumpDatabase(t *testing.T) {
3235
assert.NoError(t, DumpDatabase(filepath.Join(dir, dbType+".sql"), dbType))
3336
}
3437
}
38+
39+
func TestDumpLoginSource(t *testing.T) {
40+
assert.NoError(t, PrepareTestDatabase())
41+
42+
loginSourceSchema, err := x.TableInfo(new(LoginSource))
43+
assert.NoError(t, err)
44+
45+
CreateLoginSource(&LoginSource{
46+
Type: LoginOAuth2,
47+
Name: "TestSource",
48+
IsActived: false,
49+
Cfg: &OAuth2Config{
50+
Provider: "TestSourceProvider",
51+
CustomURLMapping: &oauth2.CustomURLMapping{},
52+
},
53+
})
54+
55+
sb := new(strings.Builder)
56+
57+
x.DumpTables([]*schemas.Table{loginSourceSchema}, sb)
58+
59+
assert.Contains(t, sb.String(), `"Provider":"TestSourceProvider"`)
60+
}

0 commit comments

Comments
 (0)