fix(cli): trim route status spacing
Remove the extra blank line between rendered route status sections and replace route test fixtures with neutral example names.
- commit
- bb8a06bd0c9ce7deea245bfa3f0481754517bb5a
- author
- brice · · 2026-04-15 14:55 UTC
- parent
- 187ed78
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +69 -38
M internal/adapters/in/cli/routes.go +1 -1
| @@ -636,7 +636,7 @@ func renderRoutesStatusSection(out io.Writer, section routeStatusSection) error | |||
| 636 | 636 | ||
| 637 | 637 | if len(section.Routes) > 0 { | |
| 638 | 638 | tree := buildRouteStatusTree(section.Routes) | |
| 639 | - | if err := cliWriteLine(out, tree.Render()); err != nil { | |
| 639 | + | if err := cliWriteLine(out, strings.TrimSuffix(tree.Render(), "\n")); err != nil { | |
| 640 | 640 | return err | |
| 641 | 641 | } | |
| 642 | 642 | } | |
| @@ -636,7 +636,7 @@ func renderRoutesStatusSection(out io.Writer, section routeStatusSection) error | |||||
| 636 | 636 | ||||
| 637 | if len(section.Routes) > 0 { | 637 | if len(section.Routes) > 0 { | ||
| 638 | tree := buildRouteStatusTree(section.Routes) | 638 | tree := buildRouteStatusTree(section.Routes) | ||
| 639 | - | if err := cliWriteLine(out, tree.Render()); err != nil { | 639 | + | if err := cliWriteLine(out, strings.TrimSuffix(tree.Render(), "\n")); err != nil { |
| 640 | return err | 640 | return err | ||
| 641 | } | 641 | } | ||
| 642 | } | 642 | } | ||
M internal/adapters/in/cli/routes_test.go +68 -37
| @@ -434,12 +434,12 @@ func TestCollectRoutesListSections_DefaultModeIncludesLocalThenSortedRemotes(t * | |||
| 434 | 434 | }, | |
| 435 | 435 | listRemotes: func() (map[string]remote.RemoteEntry, string, error) { | |
| 436 | 436 | return map[string]remote.RemoteEntry{ | |
| 437 | - | "igor": {URL: "https://gordon.supri.xyz"}, | |
| 438 | - | "hetzner-vps": {URL: "https://reg.bnema.dev"}, | |
| 439 | - | }, "igor", nil | |
| 437 | + | "remote-a": {URL: "https://remote-a.example.com"}, | |
| 438 | + | "remote-b": {URL: "https://remote-b.example.com"}, | |
| 439 | + | }, "remote-a", nil | |
| 440 | 440 | }, | |
| 441 | 441 | loadRemote: func(_ context.Context, name string, entry remote.RemoteEntry) (routeListSection, error) { | |
| 442 | - | if name == "hetzner-vps" { | |
| 442 | + | if name == "remote-b" { | |
| 443 | 443 | return routeListSection{ | |
| 444 | 444 | Kind: "remote", | |
| 445 | 445 | Name: name, | |
| @@ -452,8 +452,8 @@ func TestCollectRoutesListSections_DefaultModeIncludesLocalThenSortedRemotes(t * | |||
| 452 | 452 | Name: name, | |
| 453 | 453 | URL: entry.URL, | |
| 454 | 454 | Routes: []routeListItem{{ | |
| 455 | - | Domain: "grafana.supri.xyz", | |
| 456 | - | Image: "grafana", | |
| 455 | + | Domain: "dashboard.example.com", | |
| 456 | + | Image: "dashboard", | |
| 457 | 457 | }}, | |
| 458 | 458 | }, nil | |
| 459 | 459 | }, | |
| @@ -464,18 +464,18 @@ func TestCollectRoutesListSections_DefaultModeIncludesLocalThenSortedRemotes(t * | |||
| 464 | 464 | require.NoError(t, err) | |
| 465 | 465 | require.Len(t, sections, 3) | |
| 466 | 466 | assert.Equal(t, "local", sections[0].Name) | |
| 467 | - | assert.Equal(t, "hetzner-vps", sections[1].Name) | |
| 468 | - | assert.Equal(t, "igor", sections[2].Name) | |
| 469 | - | assert.Equal(t, "remote unavailable", sections[1].Error) | |
| 470 | - | assert.Equal(t, "grafana.supri.xyz", sections[2].Routes[0].Domain) | |
| 467 | + | assert.Equal(t, "remote-a", sections[1].Name) | |
| 468 | + | assert.Equal(t, "remote-b", sections[2].Name) | |
| 469 | + | assert.Equal(t, "dashboard.example.com", sections[1].Routes[0].Domain) | |
| 470 | + | assert.Equal(t, "remote unavailable", sections[2].Error) | |
| 471 | 471 | } | |
| 472 | 472 | ||
| 473 | 473 | func TestCollectRoutesListSections_ExplicitRemoteSkipsAggregate(t *testing.T) { | |
| 474 | 474 | testsDeps := routesListDeps{ | |
| 475 | 475 | explicitRemote: func() (*remote.ResolvedRemote, bool, error) { | |
| 476 | 476 | return &remote.ResolvedRemote{ | |
| 477 | - | Name: "igor", | |
| 478 | - | URL: "https://gordon.supri.xyz", | |
| 477 | + | Name: "remote-a", | |
| 478 | + | URL: "https://remote-a.example.com", | |
| 479 | 479 | }, true, nil | |
| 480 | 480 | }, | |
| 481 | 481 | loadLocal: func(context.Context, string) (routeListSection, error) { | |
| @@ -492,8 +492,8 @@ func TestCollectRoutesListSections_ExplicitRemoteSkipsAggregate(t *testing.T) { | |||
| 492 | 492 | Name: name, | |
| 493 | 493 | URL: entry.URL, | |
| 494 | 494 | Routes: []routeListItem{{ | |
| 495 | - | Domain: "test.supri.xyz", | |
| 496 | - | Image: "hello-test", | |
| 495 | + | Domain: "test.example.com", | |
| 496 | + | Image: "hello-app", | |
| 497 | 497 | }}, | |
| 498 | 498 | }, nil | |
| 499 | 499 | }, | |
| @@ -503,8 +503,8 @@ func TestCollectRoutesListSections_ExplicitRemoteSkipsAggregate(t *testing.T) { | |||
| 503 | 503 | ||
| 504 | 504 | require.NoError(t, err) | |
| 505 | 505 | require.Len(t, sections, 1) | |
| 506 | - | assert.Equal(t, "igor", sections[0].Name) | |
| 507 | - | assert.Equal(t, "test.supri.xyz", sections[0].Routes[0].Domain) | |
| 506 | + | assert.Equal(t, "remote-a", sections[0].Name) | |
| 507 | + | assert.Equal(t, "test.example.com", sections[0].Routes[0].Domain) | |
| 508 | 508 | } | |
| 509 | 509 | ||
| 510 | 510 | func TestCollectRoutesSections_ExplicitRemoteResolutionErrorReturnsError(t *testing.T) { | |
| @@ -581,11 +581,11 @@ func TestLoadRoutesListExplicitRemoteSection_PropagatesLoaderError(t *testing.T) | |||
| 581 | 581 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeListSection, error) { | |
| 582 | 582 | return routeListSection{}, errors.New("boom") | |
| 583 | 583 | }, | |
| 584 | - | }, &remote.ResolvedRemote{Name: "igor", URL: "https://gordon.supri.xyz"}) | |
| 584 | + | }, &remote.ResolvedRemote{Name: "remote-a", URL: "https://remote-a.example.com"}) | |
| 585 | 585 | ||
| 586 | 586 | assert.Equal(t, "remote", section.Kind) | |
| 587 | - | assert.Equal(t, "igor", section.Name) | |
| 588 | - | assert.Equal(t, "https://gordon.supri.xyz", section.URL) | |
| 587 | + | assert.Equal(t, "remote-a", section.Name) | |
| 588 | + | assert.Equal(t, "https://remote-a.example.com", section.URL) | |
| 589 | 589 | assert.Equal(t, "boom", section.Error) | |
| 590 | 590 | } | |
| 591 | 591 | ||
| @@ -594,11 +594,11 @@ func TestLoadRoutesStatusExplicitRemoteSection_PropagatesLoaderError(t *testing. | |||
| 594 | 594 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeStatusSection, error) { | |
| 595 | 595 | return routeStatusSection{}, errors.New("boom") | |
| 596 | 596 | }, | |
| 597 | - | }, &remote.ResolvedRemote{Name: "igor", URL: "https://gordon.supri.xyz"}) | |
| 597 | + | }, &remote.ResolvedRemote{Name: "remote-a", URL: "https://remote-a.example.com"}) | |
| 598 | 598 | ||
| 599 | 599 | assert.Equal(t, "remote", section.Kind) | |
| 600 | - | assert.Equal(t, "igor", section.Name) | |
| 601 | - | assert.Equal(t, "https://gordon.supri.xyz", section.URL) | |
| 600 | + | assert.Equal(t, "remote-a", section.Name) | |
| 601 | + | assert.Equal(t, "https://remote-a.example.com", section.URL) | |
| 602 | 602 | assert.Equal(t, "boom", section.Error) | |
| 603 | 603 | } | |
| 604 | 604 | ||
| @@ -612,7 +612,7 @@ func TestCollectRoutesListAggregateSections_EncodesLoaderErrors(t *testing.T) { | |||
| 612 | 612 | return map[string]remote.RemoteEntry{}, "", nil | |
| 613 | 613 | }, | |
| 614 | 614 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeListSection, error) { | |
| 615 | - | return routeListSection{Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, nil | |
| 615 | + | return routeListSection{Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, nil | |
| 616 | 616 | }, | |
| 617 | 617 | }) | |
| 618 | 618 | ||
| @@ -628,10 +628,10 @@ func TestCollectRoutesListAggregateSections_EncodesLoaderErrors(t *testing.T) { | |||
| 628 | 628 | return routeListSection{Kind: "local", Name: "local"}, nil | |
| 629 | 629 | }, | |
| 630 | 630 | listRemotes: func() (map[string]remote.RemoteEntry, string, error) { | |
| 631 | - | return map[string]remote.RemoteEntry{"igor": {URL: "https://gordon.supri.xyz"}}, "", nil | |
| 631 | + | return map[string]remote.RemoteEntry{"remote-a": {URL: "https://remote-a.example.com"}}, "", nil | |
| 632 | 632 | }, | |
| 633 | 633 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeListSection, error) { | |
| 634 | - | return routeListSection{Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, errors.New("remote failed") | |
| 634 | + | return routeListSection{Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, errors.New("remote failed") | |
| 635 | 635 | }, | |
| 636 | 636 | }) | |
| 637 | 637 | ||
| @@ -653,7 +653,7 @@ func TestCollectRoutesStatusAggregateSections_EncodesLoaderErrors(t *testing.T) | |||
| 653 | 653 | return map[string]remote.RemoteEntry{}, "", nil | |
| 654 | 654 | }, | |
| 655 | 655 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeStatusSection, error) { | |
| 656 | - | return routeStatusSection{Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, nil | |
| 656 | + | return routeStatusSection{Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, nil | |
| 657 | 657 | }, | |
| 658 | 658 | }) | |
| 659 | 659 | ||
| @@ -669,10 +669,10 @@ func TestCollectRoutesStatusAggregateSections_EncodesLoaderErrors(t *testing.T) | |||
| 669 | 669 | return routeStatusSection{Kind: "local", Name: "local"}, nil | |
| 670 | 670 | }, | |
| 671 | 671 | listRemotes: func() (map[string]remote.RemoteEntry, string, error) { | |
| 672 | - | return map[string]remote.RemoteEntry{"igor": {URL: "https://gordon.supri.xyz"}}, "", nil | |
| 672 | + | return map[string]remote.RemoteEntry{"remote-a": {URL: "https://remote-a.example.com"}}, "", nil | |
| 673 | 673 | }, | |
| 674 | 674 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeStatusSection, error) { | |
| 675 | - | return routeStatusSection{Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, errors.New("remote failed") | |
| 675 | + | return routeStatusSection{Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, errors.New("remote failed") | |
| 676 | 676 | }, | |
| 677 | 677 | }) | |
| 678 | 678 | ||
| @@ -760,8 +760,8 @@ func TestRenderRoutesStatusSections_IncludesSectionHeadingsAndErrors(t *testing. | |||
| 760 | 760 | }, | |
| 761 | 761 | { | |
| 762 | 762 | Kind: "remote", | |
| 763 | - | Name: "igor", | |
| 764 | - | URL: "https://gordon.supri.xyz", | |
| 763 | + | Name: "remote-a", | |
| 764 | + | URL: "https://remote-a.example.com", | |
| 765 | 765 | Error: "dial tcp timeout", | |
| 766 | 766 | }, | |
| 767 | 767 | } | |
| @@ -791,7 +791,7 @@ func TestRenderRoutesStatusSections_IncludesSectionHeadingsAndErrors(t *testing. | |||
| 791 | 791 | routeIdx := lineIndex("app.local") | |
| 792 | 792 | require.NotEqual(t, -1, routeIdx) | |
| 793 | 793 | ||
| 794 | - | remoteIdx := lineIndex("Remote: igor") | |
| 794 | + | remoteIdx := lineIndex("Remote: remote-a") | |
| 795 | 795 | require.NotEqual(t, -1, remoteIdx) | |
| 796 | 796 | ||
| 797 | 797 | errorIdx := lineIndex("dial tcp timeout") | |
| @@ -803,10 +803,41 @@ func TestRenderRoutesStatusSections_IncludesSectionHeadingsAndErrors(t *testing. | |||
| 803 | 803 | assert.Less(t, remoteIdx, errorIdx) | |
| 804 | 804 | } | |
| 805 | 805 | ||
| 806 | + | func TestRenderRoutesStatusSections_DoesNotAddExtraBlankLineBetweenSections(t *testing.T) { | |
| 807 | + | sections := []routeStatusSection{ | |
| 808 | + | { | |
| 809 | + | Kind: "remote", | |
| 810 | + | Name: "remote-b", | |
| 811 | + | Routes: []routeStatusItem{{ | |
| 812 | + | Domain: "app.example.com", | |
| 813 | + | Image: "app:latest", | |
| 814 | + | ContainerStatus: "running", | |
| 815 | + | }}, | |
| 816 | + | }, | |
| 817 | + | { | |
| 818 | + | Kind: "remote", | |
| 819 | + | Name: "remote-a", | |
| 820 | + | Routes: []routeStatusItem{{ | |
| 821 | + | Domain: "dashboard.example.com", | |
| 822 | + | Image: "dashboard", | |
| 823 | + | ContainerStatus: "running", | |
| 824 | + | }}, | |
| 825 | + | }, | |
| 826 | + | } | |
| 827 | + | ||
| 828 | + | var out bytes.Buffer | |
| 829 | + | err := renderRoutesStatusSections(&out, sections) | |
| 830 | + | ||
| 831 | + | require.NoError(t, err) | |
| 832 | + | rendered := stripANSI(out.String()) | |
| 833 | + | assert.NotContains(t, rendered, "app:latest\n\n\nRemote: remote-a") | |
| 834 | + | assert.Contains(t, rendered, "app:latest\n\nRemote: remote-a") | |
| 835 | + | } | |
| 836 | + | ||
| 806 | 837 | func TestRenderRoutesListSections_HidesLocalErrorWhenRemoteIsUsable(t *testing.T) { | |
| 807 | 838 | sections := []routeListSection{ | |
| 808 | 839 | {Kind: "local", Name: "local", Error: "failed to initialize local control plane"}, | |
| 809 | - | {Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, | |
| 840 | + | {Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, | |
| 810 | 841 | } | |
| 811 | 842 | ||
| 812 | 843 | var out bytes.Buffer | |
| @@ -816,14 +847,14 @@ func TestRenderRoutesListSections_HidesLocalErrorWhenRemoteIsUsable(t *testing.T | |||
| 816 | 847 | rendered := stripANSI(out.String()) | |
| 817 | 848 | assert.NotContains(t, rendered, "Local") | |
| 818 | 849 | assert.NotContains(t, rendered, "failed to initialize local control plane") | |
| 819 | - | assert.Contains(t, rendered, "Remote: igor") | |
| 850 | + | assert.Contains(t, rendered, "Remote: remote-a") | |
| 820 | 851 | assert.Contains(t, rendered, "No routes configured") | |
| 821 | 852 | } | |
| 822 | 853 | ||
| 823 | 854 | func TestRenderRoutesStatusSections_HidesLocalErrorWhenRemoteIsUsable(t *testing.T) { | |
| 824 | 855 | sections := []routeStatusSection{ | |
| 825 | 856 | {Kind: "local", Name: "local", Error: "failed to initialize local control plane"}, | |
| 826 | - | {Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, | |
| 857 | + | {Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, | |
| 827 | 858 | } | |
| 828 | 859 | ||
| 829 | 860 | var out bytes.Buffer | |
| @@ -833,14 +864,14 @@ func TestRenderRoutesStatusSections_HidesLocalErrorWhenRemoteIsUsable(t *testing | |||
| 833 | 864 | rendered := stripANSI(out.String()) | |
| 834 | 865 | assert.NotContains(t, rendered, "Local") | |
| 835 | 866 | assert.NotContains(t, rendered, "failed to initialize local control plane") | |
| 836 | - | assert.Contains(t, rendered, "Remote: igor") | |
| 867 | + | assert.Contains(t, rendered, "Remote: remote-a") | |
| 837 | 868 | assert.Contains(t, rendered, "No routes configured") | |
| 838 | 869 | } | |
| 839 | 870 | ||
| 840 | 871 | func TestRenderRoutesStatusSections_KeepsLocalErrorWhenAllRemotesFail(t *testing.T) { | |
| 841 | 872 | sections := []routeStatusSection{ | |
| 842 | 873 | {Kind: "local", Name: "local", Error: "failed to initialize local control plane"}, | |
| 843 | - | {Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz", Error: "dial tcp timeout"}, | |
| 874 | + | {Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com", Error: "dial tcp timeout"}, | |
| 844 | 875 | } | |
| 845 | 876 | ||
| 846 | 877 | var out bytes.Buffer | |
| @@ -850,7 +881,7 @@ func TestRenderRoutesStatusSections_KeepsLocalErrorWhenAllRemotesFail(t *testing | |||
| 850 | 881 | rendered := stripANSI(out.String()) | |
| 851 | 882 | assert.Contains(t, rendered, "Local") | |
| 852 | 883 | assert.Contains(t, rendered, "failed to initialize local control plane") | |
| 853 | - | assert.Contains(t, rendered, "Remote: igor") | |
| 884 | + | assert.Contains(t, rendered, "Remote: remote-a") | |
| 854 | 885 | assert.Contains(t, rendered, "dial tcp timeout") | |
| 855 | 886 | } | |
| 856 | 887 | ||
| @@ -434,12 +434,12 @@ func TestCollectRoutesListSections_DefaultModeIncludesLocalThenSortedRemotes(t * | |||||
| 434 | }, | 434 | }, | ||
| 435 | listRemotes: func() (map[string]remote.RemoteEntry, string, error) { | 435 | listRemotes: func() (map[string]remote.RemoteEntry, string, error) { | ||
| 436 | return map[string]remote.RemoteEntry{ | 436 | return map[string]remote.RemoteEntry{ | ||
| 437 | - | "igor": {URL: "https://gordon.supri.xyz"}, | 437 | + | "remote-a": {URL: "https://remote-a.example.com"}, |
| 438 | - | "hetzner-vps": {URL: "https://reg.bnema.dev"}, | 438 | + | "remote-b": {URL: "https://remote-b.example.com"}, |
| 439 | - | }, "igor", nil | 439 | + | }, "remote-a", nil |
| 440 | }, | 440 | }, | ||
| 441 | loadRemote: func(_ context.Context, name string, entry remote.RemoteEntry) (routeListSection, error) { | 441 | loadRemote: func(_ context.Context, name string, entry remote.RemoteEntry) (routeListSection, error) { | ||
| 442 | - | if name == "hetzner-vps" { | 442 | + | if name == "remote-b" { |
| 443 | return routeListSection{ | 443 | return routeListSection{ | ||
| 444 | Kind: "remote", | 444 | Kind: "remote", | ||
| 445 | Name: name, | 445 | Name: name, | ||
| @@ -452,8 +452,8 @@ func TestCollectRoutesListSections_DefaultModeIncludesLocalThenSortedRemotes(t * | |||||
| 452 | Name: name, | 452 | Name: name, | ||
| 453 | URL: entry.URL, | 453 | URL: entry.URL, | ||
| 454 | Routes: []routeListItem{{ | 454 | Routes: []routeListItem{{ | ||
| 455 | - | Domain: "grafana.supri.xyz", | 455 | + | Domain: "dashboard.example.com", |
| 456 | - | Image: "grafana", | 456 | + | Image: "dashboard", |
| 457 | }}, | 457 | }}, | ||
| 458 | }, nil | 458 | }, nil | ||
| 459 | }, | 459 | }, | ||
| @@ -464,18 +464,18 @@ func TestCollectRoutesListSections_DefaultModeIncludesLocalThenSortedRemotes(t * | |||||
| 464 | require.NoError(t, err) | 464 | require.NoError(t, err) | ||
| 465 | require.Len(t, sections, 3) | 465 | require.Len(t, sections, 3) | ||
| 466 | assert.Equal(t, "local", sections[0].Name) | 466 | assert.Equal(t, "local", sections[0].Name) | ||
| 467 | - | assert.Equal(t, "hetzner-vps", sections[1].Name) | 467 | + | assert.Equal(t, "remote-a", sections[1].Name) |
| 468 | - | assert.Equal(t, "igor", sections[2].Name) | 468 | + | assert.Equal(t, "remote-b", sections[2].Name) |
| 469 | - | assert.Equal(t, "remote unavailable", sections[1].Error) | 469 | + | assert.Equal(t, "dashboard.example.com", sections[1].Routes[0].Domain) |
| 470 | - | assert.Equal(t, "grafana.supri.xyz", sections[2].Routes[0].Domain) | 470 | + | assert.Equal(t, "remote unavailable", sections[2].Error) |
| 471 | } | 471 | } | ||
| 472 | 472 | ||||
| 473 | func TestCollectRoutesListSections_ExplicitRemoteSkipsAggregate(t *testing.T) { | 473 | func TestCollectRoutesListSections_ExplicitRemoteSkipsAggregate(t *testing.T) { | ||
| 474 | testsDeps := routesListDeps{ | 474 | testsDeps := routesListDeps{ | ||
| 475 | explicitRemote: func() (*remote.ResolvedRemote, bool, error) { | 475 | explicitRemote: func() (*remote.ResolvedRemote, bool, error) { | ||
| 476 | return &remote.ResolvedRemote{ | 476 | return &remote.ResolvedRemote{ | ||
| 477 | - | Name: "igor", | 477 | + | Name: "remote-a", |
| 478 | - | URL: "https://gordon.supri.xyz", | 478 | + | URL: "https://remote-a.example.com", |
| 479 | }, true, nil | 479 | }, true, nil | ||
| 480 | }, | 480 | }, | ||
| 481 | loadLocal: func(context.Context, string) (routeListSection, error) { | 481 | loadLocal: func(context.Context, string) (routeListSection, error) { | ||
| @@ -492,8 +492,8 @@ func TestCollectRoutesListSections_ExplicitRemoteSkipsAggregate(t *testing.T) { | |||||
| 492 | Name: name, | 492 | Name: name, | ||
| 493 | URL: entry.URL, | 493 | URL: entry.URL, | ||
| 494 | Routes: []routeListItem{{ | 494 | Routes: []routeListItem{{ | ||
| 495 | - | Domain: "test.supri.xyz", | 495 | + | Domain: "test.example.com", |
| 496 | - | Image: "hello-test", | 496 | + | Image: "hello-app", |
| 497 | }}, | 497 | }}, | ||
| 498 | }, nil | 498 | }, nil | ||
| 499 | }, | 499 | }, | ||
| @@ -503,8 +503,8 @@ func TestCollectRoutesListSections_ExplicitRemoteSkipsAggregate(t *testing.T) { | |||||
| 503 | 503 | ||||
| 504 | require.NoError(t, err) | 504 | require.NoError(t, err) | ||
| 505 | require.Len(t, sections, 1) | 505 | require.Len(t, sections, 1) | ||
| 506 | - | assert.Equal(t, "igor", sections[0].Name) | 506 | + | assert.Equal(t, "remote-a", sections[0].Name) |
| 507 | - | assert.Equal(t, "test.supri.xyz", sections[0].Routes[0].Domain) | 507 | + | assert.Equal(t, "test.example.com", sections[0].Routes[0].Domain) |
| 508 | } | 508 | } | ||
| 509 | 509 | ||||
| 510 | func TestCollectRoutesSections_ExplicitRemoteResolutionErrorReturnsError(t *testing.T) { | 510 | func TestCollectRoutesSections_ExplicitRemoteResolutionErrorReturnsError(t *testing.T) { | ||
| @@ -581,11 +581,11 @@ func TestLoadRoutesListExplicitRemoteSection_PropagatesLoaderError(t *testing.T) | |||||
| 581 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeListSection, error) { | 581 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeListSection, error) { | ||
| 582 | return routeListSection{}, errors.New("boom") | 582 | return routeListSection{}, errors.New("boom") | ||
| 583 | }, | 583 | }, | ||
| 584 | - | }, &remote.ResolvedRemote{Name: "igor", URL: "https://gordon.supri.xyz"}) | 584 | + | }, &remote.ResolvedRemote{Name: "remote-a", URL: "https://remote-a.example.com"}) |
| 585 | 585 | ||||
| 586 | assert.Equal(t, "remote", section.Kind) | 586 | assert.Equal(t, "remote", section.Kind) | ||
| 587 | - | assert.Equal(t, "igor", section.Name) | 587 | + | assert.Equal(t, "remote-a", section.Name) |
| 588 | - | assert.Equal(t, "https://gordon.supri.xyz", section.URL) | 588 | + | assert.Equal(t, "https://remote-a.example.com", section.URL) |
| 589 | assert.Equal(t, "boom", section.Error) | 589 | assert.Equal(t, "boom", section.Error) | ||
| 590 | } | 590 | } | ||
| 591 | 591 | ||||
| @@ -594,11 +594,11 @@ func TestLoadRoutesStatusExplicitRemoteSection_PropagatesLoaderError(t *testing. | |||||
| 594 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeStatusSection, error) { | 594 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeStatusSection, error) { | ||
| 595 | return routeStatusSection{}, errors.New("boom") | 595 | return routeStatusSection{}, errors.New("boom") | ||
| 596 | }, | 596 | }, | ||
| 597 | - | }, &remote.ResolvedRemote{Name: "igor", URL: "https://gordon.supri.xyz"}) | 597 | + | }, &remote.ResolvedRemote{Name: "remote-a", URL: "https://remote-a.example.com"}) |
| 598 | 598 | ||||
| 599 | assert.Equal(t, "remote", section.Kind) | 599 | assert.Equal(t, "remote", section.Kind) | ||
| 600 | - | assert.Equal(t, "igor", section.Name) | 600 | + | assert.Equal(t, "remote-a", section.Name) |
| 601 | - | assert.Equal(t, "https://gordon.supri.xyz", section.URL) | 601 | + | assert.Equal(t, "https://remote-a.example.com", section.URL) |
| 602 | assert.Equal(t, "boom", section.Error) | 602 | assert.Equal(t, "boom", section.Error) | ||
| 603 | } | 603 | } | ||
| 604 | 604 | ||||
| @@ -612,7 +612,7 @@ func TestCollectRoutesListAggregateSections_EncodesLoaderErrors(t *testing.T) { | |||||
| 612 | return map[string]remote.RemoteEntry{}, "", nil | 612 | return map[string]remote.RemoteEntry{}, "", nil | ||
| 613 | }, | 613 | }, | ||
| 614 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeListSection, error) { | 614 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeListSection, error) { | ||
| 615 | - | return routeListSection{Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, nil | 615 | + | return routeListSection{Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, nil |
| 616 | }, | 616 | }, | ||
| 617 | }) | 617 | }) | ||
| 618 | 618 | ||||
| @@ -628,10 +628,10 @@ func TestCollectRoutesListAggregateSections_EncodesLoaderErrors(t *testing.T) { | |||||
| 628 | return routeListSection{Kind: "local", Name: "local"}, nil | 628 | return routeListSection{Kind: "local", Name: "local"}, nil | ||
| 629 | }, | 629 | }, | ||
| 630 | listRemotes: func() (map[string]remote.RemoteEntry, string, error) { | 630 | listRemotes: func() (map[string]remote.RemoteEntry, string, error) { | ||
| 631 | - | return map[string]remote.RemoteEntry{"igor": {URL: "https://gordon.supri.xyz"}}, "", nil | 631 | + | return map[string]remote.RemoteEntry{"remote-a": {URL: "https://remote-a.example.com"}}, "", nil |
| 632 | }, | 632 | }, | ||
| 633 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeListSection, error) { | 633 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeListSection, error) { | ||
| 634 | - | return routeListSection{Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, errors.New("remote failed") | 634 | + | return routeListSection{Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, errors.New("remote failed") |
| 635 | }, | 635 | }, | ||
| 636 | }) | 636 | }) | ||
| 637 | 637 | ||||
| @@ -653,7 +653,7 @@ func TestCollectRoutesStatusAggregateSections_EncodesLoaderErrors(t *testing.T) | |||||
| 653 | return map[string]remote.RemoteEntry{}, "", nil | 653 | return map[string]remote.RemoteEntry{}, "", nil | ||
| 654 | }, | 654 | }, | ||
| 655 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeStatusSection, error) { | 655 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeStatusSection, error) { | ||
| 656 | - | return routeStatusSection{Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, nil | 656 | + | return routeStatusSection{Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, nil |
| 657 | }, | 657 | }, | ||
| 658 | }) | 658 | }) | ||
| 659 | 659 | ||||
| @@ -669,10 +669,10 @@ func TestCollectRoutesStatusAggregateSections_EncodesLoaderErrors(t *testing.T) | |||||
| 669 | return routeStatusSection{Kind: "local", Name: "local"}, nil | 669 | return routeStatusSection{Kind: "local", Name: "local"}, nil | ||
| 670 | }, | 670 | }, | ||
| 671 | listRemotes: func() (map[string]remote.RemoteEntry, string, error) { | 671 | listRemotes: func() (map[string]remote.RemoteEntry, string, error) { | ||
| 672 | - | return map[string]remote.RemoteEntry{"igor": {URL: "https://gordon.supri.xyz"}}, "", nil | 672 | + | return map[string]remote.RemoteEntry{"remote-a": {URL: "https://remote-a.example.com"}}, "", nil |
| 673 | }, | 673 | }, | ||
| 674 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeStatusSection, error) { | 674 | loadRemote: func(context.Context, string, remote.RemoteEntry) (routeStatusSection, error) { | ||
| 675 | - | return routeStatusSection{Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, errors.New("remote failed") | 675 | + | return routeStatusSection{Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, errors.New("remote failed") |
| 676 | }, | 676 | }, | ||
| 677 | }) | 677 | }) | ||
| 678 | 678 | ||||
| @@ -760,8 +760,8 @@ func TestRenderRoutesStatusSections_IncludesSectionHeadingsAndErrors(t *testing. | |||||
| 760 | }, | 760 | }, | ||
| 761 | { | 761 | { | ||
| 762 | Kind: "remote", | 762 | Kind: "remote", | ||
| 763 | - | Name: "igor", | 763 | + | Name: "remote-a", |
| 764 | - | URL: "https://gordon.supri.xyz", | 764 | + | URL: "https://remote-a.example.com", |
| 765 | Error: "dial tcp timeout", | 765 | Error: "dial tcp timeout", | ||
| 766 | }, | 766 | }, | ||
| 767 | } | 767 | } | ||
| @@ -791,7 +791,7 @@ func TestRenderRoutesStatusSections_IncludesSectionHeadingsAndErrors(t *testing. | |||||
| 791 | routeIdx := lineIndex("app.local") | 791 | routeIdx := lineIndex("app.local") | ||
| 792 | require.NotEqual(t, -1, routeIdx) | 792 | require.NotEqual(t, -1, routeIdx) | ||
| 793 | 793 | ||||
| 794 | - | remoteIdx := lineIndex("Remote: igor") | 794 | + | remoteIdx := lineIndex("Remote: remote-a") |
| 795 | require.NotEqual(t, -1, remoteIdx) | 795 | require.NotEqual(t, -1, remoteIdx) | ||
| 796 | 796 | ||||
| 797 | errorIdx := lineIndex("dial tcp timeout") | 797 | errorIdx := lineIndex("dial tcp timeout") | ||
| @@ -803,10 +803,41 @@ func TestRenderRoutesStatusSections_IncludesSectionHeadingsAndErrors(t *testing. | |||||
| 803 | assert.Less(t, remoteIdx, errorIdx) | 803 | assert.Less(t, remoteIdx, errorIdx) | ||
| 804 | } | 804 | } | ||
| 805 | 805 | ||||
| 806 | + | func TestRenderRoutesStatusSections_DoesNotAddExtraBlankLineBetweenSections(t *testing.T) { | |||
| 807 | + | sections := []routeStatusSection{ | |||
| 808 | + | { | |||
| 809 | + | Kind: "remote", | |||
| 810 | + | Name: "remote-b", | |||
| 811 | + | Routes: []routeStatusItem{{ | |||
| 812 | + | Domain: "app.example.com", | |||
| 813 | + | Image: "app:latest", | |||
| 814 | + | ContainerStatus: "running", | |||
| 815 | + | }}, | |||
| 816 | + | }, | |||
| 817 | + | { | |||
| 818 | + | Kind: "remote", | |||
| 819 | + | Name: "remote-a", | |||
| 820 | + | Routes: []routeStatusItem{{ | |||
| 821 | + | Domain: "dashboard.example.com", | |||
| 822 | + | Image: "dashboard", | |||
| 823 | + | ContainerStatus: "running", | |||
| 824 | + | }}, | |||
| 825 | + | }, | |||
| 826 | + | } | |||
| 827 | + | ||||
| 828 | + | var out bytes.Buffer | |||
| 829 | + | err := renderRoutesStatusSections(&out, sections) | |||
| 830 | + | ||||
| 831 | + | require.NoError(t, err) | |||
| 832 | + | rendered := stripANSI(out.String()) | |||
| 833 | + | assert.NotContains(t, rendered, "app:latest\n\n\nRemote: remote-a") | |||
| 834 | + | assert.Contains(t, rendered, "app:latest\n\nRemote: remote-a") | |||
| 835 | + | } | |||
| 836 | + | ||||
| 806 | func TestRenderRoutesListSections_HidesLocalErrorWhenRemoteIsUsable(t *testing.T) { | 837 | func TestRenderRoutesListSections_HidesLocalErrorWhenRemoteIsUsable(t *testing.T) { | ||
| 807 | sections := []routeListSection{ | 838 | sections := []routeListSection{ | ||
| 808 | {Kind: "local", Name: "local", Error: "failed to initialize local control plane"}, | 839 | {Kind: "local", Name: "local", Error: "failed to initialize local control plane"}, | ||
| 809 | - | {Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, | 840 | + | {Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, |
| 810 | } | 841 | } | ||
| 811 | 842 | ||||
| 812 | var out bytes.Buffer | 843 | var out bytes.Buffer | ||
| @@ -816,14 +847,14 @@ func TestRenderRoutesListSections_HidesLocalErrorWhenRemoteIsUsable(t *testing.T | |||||
| 816 | rendered := stripANSI(out.String()) | 847 | rendered := stripANSI(out.String()) | ||
| 817 | assert.NotContains(t, rendered, "Local") | 848 | assert.NotContains(t, rendered, "Local") | ||
| 818 | assert.NotContains(t, rendered, "failed to initialize local control plane") | 849 | assert.NotContains(t, rendered, "failed to initialize local control plane") | ||
| 819 | - | assert.Contains(t, rendered, "Remote: igor") | 850 | + | assert.Contains(t, rendered, "Remote: remote-a") |
| 820 | assert.Contains(t, rendered, "No routes configured") | 851 | assert.Contains(t, rendered, "No routes configured") | ||
| 821 | } | 852 | } | ||
| 822 | 853 | ||||
| 823 | func TestRenderRoutesStatusSections_HidesLocalErrorWhenRemoteIsUsable(t *testing.T) { | 854 | func TestRenderRoutesStatusSections_HidesLocalErrorWhenRemoteIsUsable(t *testing.T) { | ||
| 824 | sections := []routeStatusSection{ | 855 | sections := []routeStatusSection{ | ||
| 825 | {Kind: "local", Name: "local", Error: "failed to initialize local control plane"}, | 856 | {Kind: "local", Name: "local", Error: "failed to initialize local control plane"}, | ||
| 826 | - | {Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz"}, | 857 | + | {Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com"}, |
| 827 | } | 858 | } | ||
| 828 | 859 | ||||
| 829 | var out bytes.Buffer | 860 | var out bytes.Buffer | ||
| @@ -833,14 +864,14 @@ func TestRenderRoutesStatusSections_HidesLocalErrorWhenRemoteIsUsable(t *testing | |||||
| 833 | rendered := stripANSI(out.String()) | 864 | rendered := stripANSI(out.String()) | ||
| 834 | assert.NotContains(t, rendered, "Local") | 865 | assert.NotContains(t, rendered, "Local") | ||
| 835 | assert.NotContains(t, rendered, "failed to initialize local control plane") | 866 | assert.NotContains(t, rendered, "failed to initialize local control plane") | ||
| 836 | - | assert.Contains(t, rendered, "Remote: igor") | 867 | + | assert.Contains(t, rendered, "Remote: remote-a") |
| 837 | assert.Contains(t, rendered, "No routes configured") | 868 | assert.Contains(t, rendered, "No routes configured") | ||
| 838 | } | 869 | } | ||
| 839 | 870 | ||||
| 840 | func TestRenderRoutesStatusSections_KeepsLocalErrorWhenAllRemotesFail(t *testing.T) { | 871 | func TestRenderRoutesStatusSections_KeepsLocalErrorWhenAllRemotesFail(t *testing.T) { | ||
| 841 | sections := []routeStatusSection{ | 872 | sections := []routeStatusSection{ | ||
| 842 | {Kind: "local", Name: "local", Error: "failed to initialize local control plane"}, | 873 | {Kind: "local", Name: "local", Error: "failed to initialize local control plane"}, | ||
| 843 | - | {Kind: "remote", Name: "igor", URL: "https://gordon.supri.xyz", Error: "dial tcp timeout"}, | 874 | + | {Kind: "remote", Name: "remote-a", URL: "https://remote-a.example.com", Error: "dial tcp timeout"}, |
| 844 | } | 875 | } | ||
| 845 | 876 | ||||
| 846 | var out bytes.Buffer | 877 | var out bytes.Buffer | ||
| @@ -850,7 +881,7 @@ func TestRenderRoutesStatusSections_KeepsLocalErrorWhenAllRemotesFail(t *testing | |||||
| 850 | rendered := stripANSI(out.String()) | 881 | rendered := stripANSI(out.String()) | ||
| 851 | assert.Contains(t, rendered, "Local") | 882 | assert.Contains(t, rendered, "Local") | ||
| 852 | assert.Contains(t, rendered, "failed to initialize local control plane") | 883 | assert.Contains(t, rendered, "failed to initialize local control plane") | ||
| 853 | - | assert.Contains(t, rendered, "Remote: igor") | 884 | + | assert.Contains(t, rendered, "Remote: remote-a") |
| 854 | assert.Contains(t, rendered, "dial tcp timeout") | 885 | assert.Contains(t, rendered, "dial tcp timeout") | ||
| 855 | } | 886 | } | ||
| 856 | 887 | ||||