MCPcopy
hub / github.com/gofiber/fiber / Test_RoutePatternMatch_WithRegex

Function Test_RoutePatternMatch_WithRegex

path_test.go:647–661  ·  view source on GitHub ↗

Test_RoutePatternMatch_WithRegex verifies RoutePatternMatch works with regex constraints

(t *testing.T)

Source from the content-addressed store, hash-verified

645
646// Test_RoutePatternMatch_WithRegex verifies RoutePatternMatch works with regex constraints
647func Test_RoutePatternMatch_WithRegex(t *testing.T) {
648 t.Parallel()
649
650 // Test with default handler
651 require.True(t, RoutePatternMatch("/api/123", "/api/:id<regex(\\d+)>"))
652 require.False(t, RoutePatternMatch("/api/abc", "/api/:id<regex(\\d+)>"))
653
654 // Test with custom config
655 var lastPattern string
656 var compileCalled bool
657 require.True(t, RoutePatternMatch("/api/123", "/api/:id<regex(\\d+)>", Config{
658 RegexHandler: mockRegexHandler(&lastPattern, &compileCalled),
659 }))
660 require.True(t, compileCalled, "RegexHandler should have been called")
661}
662
663// Test_RegexHandler_NilDefaultsToStdlib verifies that nil RegexHandler defaults to stdlib
664func Test_RegexHandler_NilDefaultsToStdlib(t *testing.T) {

Callers

nothing calls this directly

Calls 2

RoutePatternMatchFunction · 0.85
mockRegexHandlerFunction · 0.85

Tested by

no test coverage detected