package router import ( "testing" "github.com/gin-gonic/gin" jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" ) func TestLocalEventRouterIsReadOnly(t *testing.T) { gin.SetMode(gin.TestMode) engine := gin.New() registerSenseLocalEventRouter(engine.Group("/api/v1"), &jwt.GinJWTMiddleware{}) routes := make(map[string]struct{}) for _, route := range engine.Routes() { routes[route.Method+" "+route.Path] = struct{}{} } for _, expected := range []string{"GET /api/v1/local-events", "GET /api/v1/local-events/:id"} { if _, ok := routes[expected]; !ok { t.Fatalf("missing local event route: %s", expected) } } for route := range routes { if route != "GET /api/v1/local-events" && route != "GET /api/v1/local-events/:id" { t.Fatalf("unexpected mutable local event route: %s", route) } } }