Skip to content

Commit 7b13bc0

Browse files
author
Mithilesh Gupta
committed
Added tests for v322 migration
1 parent 8b290b8 commit 7b13bc0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_25
5+
6+
import (
7+
"testing"
8+
9+
"code.gitea.io/gitea/models/migrations/base"
10+
"code.gitea.io/gitea/modules/setting"
11+
"github.com/stretchr/testify/assert"
12+
)
13+
14+
func Test_ExtendCommentTreePathLength(t *testing.T) {
15+
if setting.Database.Type.IsSQLite3() {
16+
t.Skip("For SQLITE, varchar or char will always be represented as TEXT")
17+
}
18+
19+
type Comment struct {
20+
ID int64 `xorm:"pk autoincr"`
21+
TreePath string `xorm:"VARCHAR(500)"`
22+
}
23+
24+
x, deferable := base.PrepareTestEnv(t, 0, new(Comment))
25+
defer deferable()
26+
27+
assert.NoError(t, ExtendCommentTreePathLength(x))
28+
29+
tables, err := x.DBMetas()
30+
assert.NoError(t, err)
31+
32+
for _, table := range tables {
33+
switch table.Name {
34+
case "comment":
35+
column := table.GetColumn("tree_path")
36+
assert.NotNil(t, column)
37+
assert.Equal(t, "VARCHAR", column.SQLType.Name)
38+
assert.Equal(t, 4000, column.Length)
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)