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

Function TestPathValues_GetOr

router_test.go:3591–3622  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3589}
3590
3591func TestPathValues_GetOr(t *testing.T) {
3592 var testCases = []struct {
3593 name string
3594 whenKey string
3595 whenDefaultValue string
3596 expect string
3597 }{
3598 {
3599 name: "ok, existing key",
3600 whenKey: `tag`,
3601 whenDefaultValue: `tag`,
3602 expect: `latest`,
3603 },
3604 {
3605 name: "nok, no existing key return default value",
3606 whenKey: `not existent key`,
3607 whenDefaultValue: `ok`,
3608 expect: "ok",
3609 },
3610 }
3611 for _, tc := range testCases {
3612 t.Run(tc.name, func(t *testing.T) {
3613 pv := PathValues{
3614 {Name: "image", Value: "docker"},
3615 {Name: "tag", Value: "latest"},
3616 }
3617
3618 result := pv.GetOr(tc.whenKey, tc.whenDefaultValue)
3619 assert.Equal(t, tc.expect, result)
3620 })
3621 }
3622}
3623
3624func BenchmarkRouterStaticRoutes(b *testing.B) {
3625 benchmarkRouterRoutes(b, staticRoutes, staticRoutes)

Callers

nothing calls this directly

Calls 1

GetOrMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…