32 lines
767 B
Go
32 lines
767 B
Go
package handler
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"yingce/backend/internal/service"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func TestAdminSystemPerformanceRoutesAreRegistered(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
router := gin.New()
|
|
RegisterAdminSystemPerformanceRoutes(router.Group("/api"), &service.Service{})
|
|
wanted := map[string]bool{
|
|
"GET /api/admin/system-performance": false,
|
|
"PUT /api/admin/system-performance/agent-limit": false,
|
|
"POST /api/admin/system-performance/cache/clear": false,
|
|
}
|
|
for _, route := range router.Routes() {
|
|
key := route.Method + " " + route.Path
|
|
if _, exists := wanted[key]; exists {
|
|
wanted[key] = true
|
|
}
|
|
}
|
|
for route, found := range wanted {
|
|
if !found {
|
|
t.Errorf("route %s is not registered", route)
|
|
}
|
|
}
|
|
}
|