34 lines
1.2 KiB
Go
34 lines
1.2 KiB
Go
package server
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"kra/internal/conf"
|
|
"kra/internal/server/handler"
|
|
)
|
|
|
|
func TestGinRouteContract(t *testing.T) {
|
|
handlers := &handler.Set{
|
|
Authority: &handler.Authority{}, Menu: &handler.Menu{}, API: &handler.API{},
|
|
Permission: &handler.Permission{}, Organization: &handler.Organization{},
|
|
Announcement: &handler.Announcement{}, Email: &handler.Email{}, Task: &handler.Task{},
|
|
Media: &handler.Media{}, Audit: &handler.Audit{}, Export: &handler.Export{},
|
|
Version: &handler.Version{}, Dictionary: &handler.Dictionary{}, Parameter: &handler.Parameter{},
|
|
APIToken: &handler.APIToken{}, SystemConfig: &handler.SystemConfig{}, Public: &handler.Public{},
|
|
User: &handler.User{}, Navigation: &handler.Navigation{}, Session: &handler.Session{},
|
|
}
|
|
engine := NewGinEngine(conf.NewRuntime(nil, &conf.AdminBackend{}), nil, handlers, nil, nil, nil, nil, "test")
|
|
routes := engine.Routes()
|
|
if len(routes) != 177 {
|
|
t.Fatalf("route contract changed: got %d routes, want 177", len(routes))
|
|
}
|
|
seen := make(map[string]struct{}, len(routes))
|
|
for _, route := range routes {
|
|
key := route.Method + " " + route.Path
|
|
if _, exists := seen[key]; exists {
|
|
t.Fatalf("duplicate route %s", key)
|
|
}
|
|
seen[key] = struct{}{}
|
|
}
|
|
}
|