Skip to content

Commit e326d00

Browse files
committed
fix
1 parent 775421e commit e326d00

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

models/migrations/v1_16/v210_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"code.gitea.io/gitea/modules/timeutil"
1111

1212
"github.com/stretchr/testify/assert"
13+
"github.com/stretchr/testify/require"
1314
"xorm.io/xorm/schemas"
1415
)
1516

@@ -56,10 +57,7 @@ func Test_RemigrateU2FCredentials(t *testing.T) {
5657
}
5758

5859
// Run the migration
59-
if err := RemigrateU2FCredentials(x); err != nil {
60-
assert.NoError(t, err)
61-
return
62-
}
60+
require.NoError(t, RemigrateU2FCredentials(x))
6361

6462
expected := []ExpectedWebauthnCredential{}
6563
if err := x.Table("expected_webauthn_credential").Asc("id").Find(&expected); !assert.NoError(t, err) {

models/unittest/fixtures_loader.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ type fixturesLoader struct {
2525
func (f *fixturesLoader) prepareFieldValue(v any) any {
2626
if s, ok := v.(string); ok {
2727
if strings.HasPrefix(s, "::HEX::") {
28-
b, _ := hex.DecodeString(s[8:])
28+
b, _ := hex.DecodeString(s[7:])
2929
return b
3030
}
3131
}
3232
return v
3333
}
34+
3435
func (f *fixturesLoader) loadFixtures(file string) error {
3536
data, err := os.ReadFile(file)
3637
if err != nil {
@@ -51,10 +52,8 @@ func (f *fixturesLoader) loadFixtures(file string) error {
5152

5253
switch f.engine.Dialect().URI().DBType {
5354
case schemas.MSSQL:
54-
_, _ = f.engine.Exec("SET IDENTITY_INSERT [%s] ON", tableName)
55-
defer func() {
56-
_, _ = f.engine.Exec("SET IDENTITY_INSERT [%s] OFF", tableName)
57-
}()
55+
_, _ = f.engine.Exec(fmt.Sprintf("SET IDENTITY_INSERT `%s` ON", tableName))
56+
// we can't revert this behavior, because some tests also depends on this, for example: Test_UpdateBadgeColName
5857
}
5958

6059
var sqlBuf []byte

modules/system/appstate_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ func (*testItem2) Name() string {
3636
}
3737

3838
func TestAppStateDB(t *testing.T) {
39-
assert.NoError(t, unittest.PrepareTestDatabase())
40-
4139
as := &DBStore{}
4240

4341
item1 := new(testItem1)

0 commit comments

Comments
 (0)