MCPcopy Create free account
hub / github.com/gavv/httpexpect / TestChain_AliasedPath

Function TestChain_AliasedPath

chain_test.go:591–636  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

589}
590
591func TestChain_AliasedPath(t *testing.T) {
592 path := func(c *chain) string {
593 return strings.Join(c.context.Path, ".")
594 }
595 aliasedPath := func(c *chain) string {
596 return strings.Join(c.context.AliasedPath, ".")
597 }
598
599 t.Run("enter and leave", func(t *testing.T) {
600 rootChain := newChainWithDefaults("root", newMockReporter(t))
601
602 assert.Equal(t, "root", path(rootChain))
603 assert.Equal(t, "root", aliasedPath(rootChain))
604
605 c1 := rootChain.enter("foo")
606 assert.Equal(t, "root.foo", path(c1))
607 assert.Equal(t, "root.foo", aliasedPath(c1))
608
609 c2 := c1.enter("bar")
610 assert.Equal(t, "root.foo.bar", path(c2))
611 assert.Equal(t, "root.foo.bar", aliasedPath(c2))
612
613 c2.setAlias("alias1")
614 assert.Equal(t, "root.foo.bar", path(c2))
615 assert.Equal(t, "alias1", aliasedPath(c2))
616
617 c3 := c2.enter("baz")
618 assert.Equal(t, "root.foo.bar.baz", path(c3))
619 assert.Equal(t, "alias1.baz", aliasedPath(c3))
620
621 c3.leave()
622 assert.Equal(t, "root.foo.bar.baz", path(c3))
623 assert.Equal(t, "alias1.baz", aliasedPath(c3))
624 })
625
626 t.Run("set empty", func(t *testing.T) {
627 rootChain := newChainWithDefaults("root", newMockReporter(t))
628
629 assert.Equal(t, "root", path(rootChain))
630 assert.Equal(t, "root", aliasedPath(rootChain))
631
632 rootChain.setAlias("")
633 assert.Equal(t, "root", path(rootChain))
634 assert.Equal(t, "", aliasedPath(rootChain))
635 })
636}
637
638func TestChain_Handler(t *testing.T) {
639 t.Run("success", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

newChainWithDefaultsFunction · 0.85
newMockReporterFunction · 0.85
enterMethod · 0.80
setAliasMethod · 0.80
leaveMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…