feat: 迁移日汇总任务并修复商务菜单图标
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package business
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestBusinessMenuIconsRepairLegacyAndPreserveCustom(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
if err := db.Exec("CREATE TABLE sys_base_menus(id INTEGER PRIMARY KEY,name TEXT,icon TEXT)").Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, sql := range []string{
|
||||
"INSERT INTO sys_base_menus VALUES(1,'sw_BusMgmt','category'),(2,'sw_BusinessList','email'),(3,'sw_ChannelList','Connection'),(4,'sw_ChannelActivationList','CirclePlus'),(5,'sw_DataAnalysis',NULL),(6,'dashboard','category')",
|
||||
} {
|
||||
if err := db.Exec(sql).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
for attempt := 0; attempt < 2; attempt++ {
|
||||
if err := migrateBusinessMenuIcons(db); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
var rows []struct {
|
||||
ID int
|
||||
Icon string
|
||||
}
|
||||
if err := db.Table("sys_base_menus").Order("id").Scan(&rows).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for i, want := range []string{"Briefcase", "UserFilled", "Connection", "CirclePlus", "DataAnalysis", "category"} {
|
||||
if rows[i].Icon != want {
|
||||
t.Fatalf("菜单%d图标错误或误改自定义值: %+v", i, rows)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user