优化结构

This commit is contained in:
Yvan
2026-08-27 19:08:51 +08:00
parent 653414a1da
commit 5052835fcb
11 changed files with 197 additions and 19 deletions
+20 -1
View File
@@ -20,7 +20,11 @@ func TestSeedSystemCreatesInitialDataAndModuleSurface(t *testing.T) {
Menus: []platformmodule.Menu{{Name: "orders", Path: "orders", ParentName: "extensions", Component: "view/orders.vue", Title: "订单", Sort: 6}},
APIs: []platformmodule.API{{Path: "/orders", Method: "GET", Group: "订单", Description: "订单列表"}},
}
input := &system.DatabaseConfig{AdminPassword: "admin-password", APIs: []*system.API{{Path: "/healthz", Method: "GET", APIGroup: "系统"}}}
input := &system.DatabaseConfig{AdminPassword: "admin-password", APIs: []*system.API{
{Path: "/healthz", Method: "GET", APIGroup: "系统"},
{Path: "/files/*filepath", Method: "GET", APIGroup: "静态文件"},
{Path: "/files/*filepath", Method: "HEAD", APIGroup: "静态文件"},
}}
if err = SeedSystem(context.Background(), db, input, surface); err != nil {
t.Fatal(err)
}
@@ -53,4 +57,19 @@ func TestSeedSystemCreatesInitialDataAndModuleSurface(t *testing.T) {
if policies != 1 {
t.Fatalf("root policies = %d, want 1", policies)
}
for _, method := range []string{"GET", "HEAD"} {
var ignored int64
if err = db.Model(&ignoredAPIPO{}).Where("path = ? AND method = ?", "/files/*filepath", method).Count(&ignored).Error; err != nil {
t.Fatal(err)
}
if ignored != 1 {
t.Fatalf("dynamic static route %s ignored rows = %d, want 1", method, ignored)
}
if err = policyScope(db).Where("v0 = ? AND v1 = ? AND v2 = ?", "888", "/files/*filepath", method).Count(&policies).Error; err != nil {
t.Fatal(err)
}
if policies != 0 {
t.Fatalf("dynamic static route %s received root policy", method)
}
}
}