Skip to content

Commit 15697dc

Browse files
committed
fix more
1 parent cc4dbd9 commit 15697dc

File tree

5 files changed

+49
-36
lines changed

5 files changed

+49
-36
lines changed

models/migrations/migrations.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"code.gitea.io/gitea/models/migrations/v1_23"
2626
"code.gitea.io/gitea/models/migrations/v1_24"
2727
"code.gitea.io/gitea/models/migrations/v1_25"
28+
"code.gitea.io/gitea/models/migrations/v1_26"
2829
"code.gitea.io/gitea/models/migrations/v1_6"
2930
"code.gitea.io/gitea/models/migrations/v1_7"
3031
"code.gitea.io/gitea/models/migrations/v1_8"
@@ -394,7 +395,9 @@ func prepareMigrationTasks() []*migration {
394395
// Gitea 1.24.0 ends at database version 321
395396
newMigration(321, "Use LONGTEXT for some columns and fix review_state.updated_files column", v1_25.UseLongTextInSomeColumnsAndFixBugs),
396397
newMigration(322, "Extend comment tree_path length limit", v1_25.ExtendCommentTreePathLength),
397-
newMigration(323, "Add support for actions concurrency", v1_25.AddActionsConcurrency),
398+
399+
// Gitea 1.25.0 ends at migration ID number 322 (database version 323)
400+
newMigration(323, "Add support for actions concurrency", v1_26.AddActionsConcurrency),
398401
}
399402
return preparedMigrations
400403
}

models/migrations/v1_25/v321_test.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"code.gitea.io/gitea/modules/timeutil"
1212

1313
"github.com/stretchr/testify/assert"
14+
"github.com/stretchr/testify/require"
1415
)
1516

1617
func Test_UseLongTextInSomeColumnsAndFixBugs(t *testing.T) {
@@ -43,28 +44,26 @@ func Test_UseLongTextInSomeColumnsAndFixBugs(t *testing.T) {
4344
}
4445

4546
// Prepare and load the testing database
46-
x, deferable := base.PrepareTestEnv(t, 0, new(ReviewState), new(PackageProperty), new(Notice))
47-
defer deferable()
47+
x, deferrable := base.PrepareTestEnv(t, 0, new(ReviewState), new(PackageProperty), new(Notice))
48+
defer deferrable()
4849

4950
assert.NoError(t, UseLongTextInSomeColumnsAndFixBugs(x))
5051

51-
tables, err := x.DBMetas()
52-
assert.NoError(t, err)
52+
table, err := x.TableInfo("review_state")
53+
require.NoError(t, err)
54+
column := table.GetColumn("updated_files")
55+
require.NotNil(t, column)
56+
assert.Equal(t, "LONGTEXT", column.SQLType.Name)
5357

54-
for _, table := range tables {
55-
switch table.Name {
56-
case "review_state":
57-
column := table.GetColumn("updated_files")
58-
assert.NotNil(t, column)
59-
assert.Equal(t, "LONGTEXT", column.SQLType.Name)
60-
case "package_property":
61-
column := table.GetColumn("value")
62-
assert.NotNil(t, column)
63-
assert.Equal(t, "LONGTEXT", column.SQLType.Name)
64-
case "notice":
65-
column := table.GetColumn("description")
66-
assert.NotNil(t, column)
67-
assert.Equal(t, "LONGTEXT", column.SQLType.Name)
68-
}
69-
}
58+
table, err = x.TableInfo("package_property")
59+
require.NoError(t, err)
60+
column = table.GetColumn("value")
61+
require.NotNil(t, column)
62+
assert.Equal(t, "LONGTEXT", column.SQLType.Name)
63+
64+
table, err = x.TableInfo("notice")
65+
require.NoError(t, err)
66+
column = table.GetColumn("description")
67+
require.NotNil(t, column)
68+
assert.Equal(t, "LONGTEXT", column.SQLType.Name)
7069
}

models/migrations/v1_25/v322_test.go

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

1212
"github.com/stretchr/testify/assert"
13+
"github.com/stretchr/testify/require"
1314
)
1415

1516
func Test_ExtendCommentTreePathLength(t *testing.T) {
@@ -22,21 +23,17 @@ func Test_ExtendCommentTreePathLength(t *testing.T) {
2223
TreePath string `xorm:"VARCHAR(255)"`
2324
}
2425

25-
x, deferable := base.PrepareTestEnv(t, 0, new(Comment))
26-
defer deferable()
26+
x, deferrable := base.PrepareTestEnv(t, 0, new(Comment))
27+
defer deferrable()
2728

28-
assert.NoError(t, ExtendCommentTreePathLength(x))
29+
require.NoError(t, ExtendCommentTreePathLength(x))
2930

30-
tables, err := x.DBMetas()
31-
assert.NoError(t, err)
31+
table, err := x.TableInfo("comment")
32+
require.NoError(t, err)
3233

33-
for _, table := range tables {
34-
switch table.Name {
35-
case "comment":
36-
column := table.GetColumn("tree_path")
37-
assert.NotNil(t, column)
38-
assert.Contains(t, []string{"NVARCHAR", "VARCHAR"}, column.SQLType.Name)
39-
assert.Equal(t, int64(4000), column.Length)
40-
}
41-
}
34+
column := table.GetColumn("tree_path")
35+
require.NotNil(t, column)
36+
37+
assert.Contains(t, []string{"NVARCHAR", "VARCHAR"}, column.SQLType.Name)
38+
assert.EqualValues(t, 4000, column.Length)
4239
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_26
5+
6+
import (
7+
"testing"
8+
9+
"code.gitea.io/gitea/models/migrations/base"
10+
)
11+
12+
func TestMain(m *testing.M) {
13+
base.MainTest(m)
14+
}

models/migrations/v1_25/v323.go renamed to models/migrations/v1_26/v323.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2025 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
package v1_25
4+
package v1_26
55

66
import (
77
"xorm.io/xorm"

0 commit comments

Comments
 (0)