优化结构
This commit is contained in:
@@ -4,8 +4,10 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
integrationmodule "kra/internal/modules/integration"
|
||||
paymentmodule "kra/internal/modules/payment"
|
||||
systemmodule "kra/internal/modules/system"
|
||||
taskmodule "kra/internal/modules/task"
|
||||
"kra/pkg/module"
|
||||
platformtask "kra/pkg/task"
|
||||
)
|
||||
@@ -17,6 +19,8 @@ import (
|
||||
func Catalog() module.Catalog {
|
||||
return module.Catalog{Definitions: []module.Definition{
|
||||
systemmodule.Definition(),
|
||||
integrationmodule.Definition(),
|
||||
taskmodule.Definition(),
|
||||
paymentmodule.Definition(),
|
||||
}}
|
||||
}
|
||||
|
||||
@@ -10,16 +10,28 @@ import (
|
||||
platformtask "kra/pkg/task"
|
||||
)
|
||||
|
||||
func TestCatalogMigrationIDsAreUnique(t *testing.T) {
|
||||
seen := map[string]string{}
|
||||
for _, definition := range Catalog().Definitions {
|
||||
for _, step := range definition.Migrations {
|
||||
if previous, exists := seen[step.ID]; exists {
|
||||
t.Fatalf("migration %q is declared by both %s and %s", step.ID, previous, definition.Name)
|
||||
}
|
||||
seen[step.ID] = definition.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCatalogIncludesSystemDefinition(t *testing.T) {
|
||||
catalog := Catalog()
|
||||
if len(catalog.Definitions) != 2 {
|
||||
t.Fatalf("definitions = %d, want 2", len(catalog.Definitions))
|
||||
if len(catalog.Definitions) != 4 {
|
||||
t.Fatalf("definitions = %d, want 4", len(catalog.Definitions))
|
||||
}
|
||||
if catalog.Definitions[0].Name != "system" || catalog.Definitions[1].Name != "payment" {
|
||||
t.Fatalf("definition order = [%q, %q], want [system, payment]", catalog.Definitions[0].Name, catalog.Definitions[1].Name)
|
||||
if catalog.Definitions[0].Name != "system" || catalog.Definitions[1].Name != "integration" || catalog.Definitions[2].Name != "task" || catalog.Definitions[3].Name != "payment" {
|
||||
t.Fatalf("definition order = [%q, %q, %q, %q], want [system, integration, task, payment]", catalog.Definitions[0].Name, catalog.Definitions[1].Name, catalog.Definitions[2].Name, catalog.Definitions[3].Name)
|
||||
}
|
||||
if got := catalog.MigrationSteps(); len(got) != 5 {
|
||||
t.Fatalf("module migrations = %d, want 5", len(got))
|
||||
if got := catalog.MigrationSteps(); len(got) != 8 {
|
||||
t.Fatalf("module migrations = %d, want 8", len(got))
|
||||
}
|
||||
if surface := catalog.Surface(); len(surface.Menus) != 3 || len(surface.APIs) != 15 {
|
||||
t.Fatalf("admin surface = %d menus/%d APIs, want 3/15", len(surface.Menus), len(surface.APIs))
|
||||
|
||||
Reference in New Issue
Block a user