MCPcopy
hub / github.com/gorilla/mux / TestMatcherFunc

Function TestMatcherFunc

mux_test.go:1129–1161  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1127}
1128
1129func TestMatcherFunc(t *testing.T) {
1130 m := func(r *http.Request, m *RouteMatch) bool {
1131 return r.URL.Host == "aaa.bbb.ccc"
1132 }
1133
1134 tests := []routeTest{
1135 {
1136 title: "MatchFunc route, match",
1137 route: new(Route).MatcherFunc(m),
1138 request: newRequest("GET", "http://aaa.bbb.ccc"),
1139 vars: map[string]string{},
1140 host: "",
1141 path: "",
1142 shouldMatch: true,
1143 },
1144 {
1145 title: "MatchFunc route, non-match",
1146 route: new(Route).MatcherFunc(m),
1147 request: newRequest("GET", "http://aaa.222.ccc"),
1148 vars: map[string]string{},
1149 host: "",
1150 path: "",
1151 shouldMatch: false,
1152 },
1153 }
1154
1155 for _, test := range tests {
1156 t.Run(test.title, func(t *testing.T) {
1157 testRoute(t, test)
1158 testTemplate(t, test)
1159 })
1160 }
1161}
1162
1163func TestBuildVarsFunc(t *testing.T) {
1164 tests := []routeTest{

Callers

nothing calls this directly

Calls 4

newRequestFunction · 0.85
testRouteFunction · 0.85
testTemplateFunction · 0.85
MatcherFuncMethod · 0.45

Tested by

no test coverage detected