-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_test.go
44 lines (36 loc) · 1.36 KB
/
gen_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package gormmom
import (
"testing"
"time"
"github.com/yyle88/gormmom/gormmomname"
"github.com/yyle88/runpath"
)
func TestMain(m *testing.M) {
m.Run()
}
type Example struct {
ID int32 `gorm:"column:id; primaryKey;" json:"id"`
V名称 string `gorm:"type:text" mom:"naming:S63"`
V字段 string `gorm:"column: some_field" mom:"naming:S63;"`
V性别 string
V特殊 string `gorm:"column:特殊;type:int32" mom:"naming:S63;"`
V年龄 int `json:"age"` //理论上不要直接给model添加json标签,因为那是view层的逻辑,但实际上假如非这样做也能处理
Rank int32 `` //看看这种情况是啥效果
V身高 int32 `` //看看这种情况是啥效果
V体重 int32 `` //看看这种情况是啥效果
// v啥呀 string //这个是小写字母开头的所以不是导出字段
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
}
func TestGetNewCode(t *testing.T) {
cfg := NewConfig(NewSchemaCacheV2[Example](runpath.CurrentPath()), NewOptions())
t.Log(cfg)
newCode := cfg.GetNewCode()
t.Log(string(newCode))
}
func TestGetNewCode_S63(t *testing.T) {
cfg := NewConfig(NewSchemaCacheV2[Example](runpath.CurrentPath()), NewOptions().WithDefaultColumnNamePattern(gormmomname.Uppercase63))
t.Log(cfg)
newCode := cfg.GetNewCode()
t.Log(string(newCode))
}