1 Star 1 Fork 0

李寻欢 / xt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
xt_test.go 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
李寻欢 提交于 2023-03-28 14:06 . :arrow_up:更新相关依赖到最新版
package xt
import (
"github.com/lixh00/xt/utils"
"testing"
)
type User struct {
Id uint `json:"id" gorm:"primary_key"`
Name string `json:"name" form:"type:varchar(20);not null;comment:'姓名'"`
Age int `json:"age" gorm:"type:tinyint(3);default:1;not null;comment:'年龄'"`
}
func (User) TableName() string {
return "test_user"
}
type UserInfo struct {
Id uint `json:"id" gorm:"primary_key"`
Sex string `json:"sex" form:"type:varchar(20);not null;comment:'姓名'"`
Avatar int `json:"avatar" gorm:"type:tinyint(3);default:1;not null;comment:'年龄'"`
}
func (UserInfo) TableName() string {
return "test_user_info"
}
func getDBS() []DatabaseClientInfo {
var dbs []DatabaseClientInfo
dbs = append(dbs, DatabaseClientInfo{
TenantId: "1",
Info: TenantInfo{
Name: "李寻欢测试",
ShortName: "测试",
Logo: "",
TypeCode: "school",
},
Host: "10.11.0.10",
Port: 3307,
User: "saas",
Password: "saas123",
Db: "saas_hsxl",
})
return dbs
}
func TestSyncModels(t *testing.T) {
_ = AddModel(User{})
_ = AddModel(UserInfo{})
//DisableSyncModels(true)
SetSyncModelsAsync(true)
err := Init(getDBS, nil, true)
if err != nil {
return
}
_, err = GetByTenantId("1")
if err != nil {
return
}
t.Log("成功")
}
// 更新租户信息
func TestSyncTenantInfo(t *testing.T) {
inIds := []uint{1, 2, 3}
newIds := []uint{1, 2, 4}
needClearIds := utils.Difference(inIds, newIds)
t.Logf("需要清理的Id: %v", needClearIds)
}
1
https://gitee.com/best_lxh/xt.git
git@gitee.com:best_lxh/xt.git
best_lxh
xt
xt
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891