test(daemon): assert floating structural error messages and no chain leak
- commit
- cd082276e0d48cd4e7dbaea6d8b9ebf155736429
- author
- brice · · 2026-07-20 17:54 UTC
- parent
- bdb821c
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +11 -6
M internal/usecase/daemon/floating_test.go +11 -6
| @@ -594,12 +594,14 @@ func TestFloatingInstallLogsSessionNameSafelyDuringRename(t *testing.T) { | |||
| 594 | 594 | ||
| 595 | 595 | func TestToggleFloatingStructuralErrorsAreUserErrors(t *testing.T) { | |
| 596 | 596 | tests := []struct { | |
| 597 | - | name string | |
| 598 | - | d *Daemon | |
| 599 | - | sess *session | |
| 597 | + | name string | |
| 598 | + | d *Daemon | |
| 599 | + | sess *session | |
| 600 | + | wantMsg string | |
| 601 | + | cause error | |
| 600 | 602 | }{ | |
| 601 | - | {"nil session", newTestDaemon(t, nil, stubClock{}), nil}, | |
| 602 | - | {"no active tab", newTestDaemon(t, nil, stubClock{}), &session{}}, | |
| 603 | + | {"nil session", newTestDaemon(t, nil, stubClock{}), nil, "couldn't open floating pane: no active session", nil}, | |
| 604 | + | {"no active tab", newTestDaemon(t, nil, stubClock{}), &session{}, "couldn't open floating pane: no active tab", layout.ErrNotFound}, | |
| 603 | 605 | } | |
| 604 | 606 | for _, tc := range tests { | |
| 605 | 607 | t.Run(tc.name, func(t *testing.T) { | |
| @@ -610,7 +612,10 @@ func TestToggleFloatingStructuralErrorsAreUserErrors(t *testing.T) { | |||
| 610 | 612 | require.ErrorAs(t, err, &ue) | |
| 611 | 613 | require.Equal(t, domain.NoticeFloatingSpawn, ue.Code) | |
| 612 | 614 | require.Equal(t, domain.NoticeError, ue.Severity) | |
| 613 | - | require.NotEmpty(t, ue.Msg) | |
| 615 | + | require.Equal(t, tc.wantMsg, ue.Msg) | |
| 616 | + | if tc.cause != nil { | |
| 617 | + | require.NotContains(t, ue.Msg, tc.cause.Error()) | |
| 618 | + | } | |
| 614 | 619 | }) | |
| 615 | 620 | } | |
| 616 | 621 | } | |
| @@ -594,12 +594,14 @@ func TestFloatingInstallLogsSessionNameSafelyDuringRename(t *testing.T) { | |||||
| 594 | 594 | ||||
| 595 | func TestToggleFloatingStructuralErrorsAreUserErrors(t *testing.T) { | 595 | func TestToggleFloatingStructuralErrorsAreUserErrors(t *testing.T) { | ||
| 596 | tests := []struct { | 596 | tests := []struct { | ||
| 597 | - | name string | 597 | + | name string |
| 598 | - | d *Daemon | 598 | + | d *Daemon |
| 599 | - | sess *session | 599 | + | sess *session |
| 600 | + | wantMsg string | |||
| 601 | + | cause error | |||
| 600 | }{ | 602 | }{ | ||
| 601 | - | {"nil session", newTestDaemon(t, nil, stubClock{}), nil}, | 603 | + | {"nil session", newTestDaemon(t, nil, stubClock{}), nil, "couldn't open floating pane: no active session", nil}, |
| 602 | - | {"no active tab", newTestDaemon(t, nil, stubClock{}), &session{}}, | 604 | + | {"no active tab", newTestDaemon(t, nil, stubClock{}), &session{}, "couldn't open floating pane: no active tab", layout.ErrNotFound}, |
| 603 | } | 605 | } | ||
| 604 | for _, tc := range tests { | 606 | for _, tc := range tests { | ||
| 605 | t.Run(tc.name, func(t *testing.T) { | 607 | t.Run(tc.name, func(t *testing.T) { | ||
| @@ -610,7 +612,10 @@ func TestToggleFloatingStructuralErrorsAreUserErrors(t *testing.T) { | |||||
| 610 | require.ErrorAs(t, err, &ue) | 612 | require.ErrorAs(t, err, &ue) | ||
| 611 | require.Equal(t, domain.NoticeFloatingSpawn, ue.Code) | 613 | require.Equal(t, domain.NoticeFloatingSpawn, ue.Code) | ||
| 612 | require.Equal(t, domain.NoticeError, ue.Severity) | 614 | require.Equal(t, domain.NoticeError, ue.Severity) | ||
| 613 | - | require.NotEmpty(t, ue.Msg) | 615 | + | require.Equal(t, tc.wantMsg, ue.Msg) |
| 616 | + | if tc.cause != nil { | |||
| 617 | + | require.NotContains(t, ue.Msg, tc.cause.Error()) | |||
| 618 | + | } | |||
| 614 | }) | 619 | }) | ||
| 615 | } | 620 | } | ||
| 616 | } | 621 | } | ||