(t *testing.T)
| 589 | } |
| 590 | |
| 591 | func 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 | |
| 638 | func TestChain_Handler(t *testing.T) { |
| 639 | t.Run("success", func(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…