MCPcopy Create free account
hub / github.com/kataras/iris / TestSwitchJoin

Function TestSwitchJoin

apps/switch_test.go:10–37  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestSwitchJoin(t *testing.T) {
11 myapp := iris.New()
12 customFilter := func(ctx iris.Context) bool {
13 pass, _ := ctx.URLParamBool("filter")
14 return pass
15 }
16
17 joinedCases := Join{
18 SwitchCase{
19 Filter: customFilter,
20 App: myapp,
21 },
22 Hosts{{Pattern: "^test.*$", Target: myapp}},
23 }
24
25 cases := []SwitchCase{
26 {
27 Filter: customFilter,
28 App: myapp,
29 },
30 {Filter: hostFilter("^test.*$"), App: myapp},
31 }
32
33 if expected, got := fmt.Sprintf("%#+v", cases), fmt.Sprintf("%#+v", joinedCases.GetSwitchCases()); expected != got {
34 t.Fatalf("join does not match with the expected slice of cases, expected:\n%s\nbut got:\n%s", expected, got)
35 }
36
37}

Callers

nothing calls this directly

Calls 5

GetSwitchCasesMethod · 0.95
hostFilterFunction · 0.85
NewMethod · 0.80
URLParamBoolMethod · 0.80
FatalfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…