MCPcopy Index your code
hub / github.com/coder/coder / Test_RoutePatterns

Function Test_RoutePatterns

coderd/httpmw/patternmatcher/routepatterns_test.go:11–134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func Test_RoutePatterns(t *testing.T) {
12 t.Parallel()
13
14 cases := []struct {
15 name string
16 patterns []string
17 errContains string
18 output string
19 }{
20 {
21 name: "Empty",
22 patterns: []string{},
23 output: "^()$",
24 },
25 {
26 name: "Single",
27 patterns: []string{
28 "/api",
29 },
30 output: "^(/api/?)$",
31 },
32 {
33 name: "TrailingSlash",
34 patterns: []string{
35 "/api/",
36 },
37 output: "^(/api/)$",
38 },
39 {
40 name: "Multiple",
41 patterns: []string{
42 "/api",
43 "/api2",
44 },
45 output: "^(/api/?|/api2/?)$",
46 },
47 {
48 name: "Star",
49 patterns: []string{
50 "/api/*",
51 },
52 output: "^(/api/[^/]+/?)$",
53 },
54 {
55 name: "StarStar",
56 patterns: []string{
57 "/api/**",
58 },
59 output: "^(/api/.+/?)$",
60 },
61 {
62 name: "TelemetryPatterns",
63 patterns: []string{
64 "/api",
65 "/api/**",
66 "/@*/*/apps/**",
67 "/%40*/*/apps/**",
68 "/external-auth/*/callback",

Callers

nothing calls this directly

Calls 7

RoutePatternsTypeAlias · 0.92
CompileMethod · 0.80
MustCompileMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected