MCPcopy
hub / github.com/labstack/echo / TestRouteInfo

Function TestRouteInfo

context_test.go:1517–1543  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1515}
1516
1517func TestRouteInfo(t *testing.T) {
1518 e := New()
1519 c := e.NewContext(nil, nil)
1520
1521 orgRI := RouteInfo{
1522 Name: "root",
1523 Method: http.MethodGet,
1524 Path: "/*",
1525 Parameters: []string{"*"},
1526 }
1527 c.route = &orgRI
1528 ri := c.RouteInfo()
1529 assert.Equal(t, orgRI, ri)
1530
1531 // Test mutability when middlewares start to change things
1532
1533 // RouteInfo inside context will not be affected when returned instance is changed
1534 expect := orgRI.Clone()
1535 ri.Path = "changed"
1536 ri.Parameters[0] = "changed"
1537 assert.Equal(t, expect, c.RouteInfo())
1538
1539 // RouteInfo inside context will not be affected when returned instance is changed
1540 expect = c.RouteInfo()
1541 orgRI.Name = "changed"
1542 assert.NotEqual(t, expect, c.RouteInfo())
1543}

Callers

nothing calls this directly

Calls 4

RouteInfoMethod · 0.95
CloneMethod · 0.95
NewFunction · 0.85
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…