v2.31.0-dev5 4162c86

deploy_error_test.go RawHistoryFolder

1package cli
2
3import (
4	"errors"
5	"testing"
6
7	"github.com/stretchr/testify/assert"
8	"github.com/stretchr/testify/require"
9
10	"github.com/bnema/gordon/internal/adapters/in/cli/remote"
11	"github.com/bnema/gordon/internal/domain"
12)
13
14func TestFormatDeployFailure_RemoteStructuredError(t *testing.T) {
15	root := &remote.HTTPError{
16		StatusCode: 500,
17		Status:     "500 Internal Server Error",
18		Body:       "failed to deploy",
19		Cause:      "health check failed",
20		Hint:       "check DATABASE_URL",
21		Logs: []string{
22			"booting app",
23			"connection refused",
24		},
25	}
26	err := formatDeployFailure(root)
27
28	require.Error(t, err)
29	assert.Equal(t, "failed to deploy\nCause: health check failed\nHint: check DATABASE_URL\n\nRecent container logs:\n  booting app\n  connection refused", err.Error())
30	assert.ErrorIs(t, err, root)
31}
32
33func TestFormatDeployFailure_LocalTypedError(t *testing.T) {
34	root := &domain.DeployFailureError{
35		Summary: "failed to deploy",
36		Cause:   "health check failed",
37		Hint:    "check DATABASE_URL",
38		Logs: []string{
39			"booting app",
40			"connection refused",
41		},
42	}
43	err := formatDeployFailure(root)
44
45	require.Error(t, err)
46	assert.Equal(t, "failed to deploy\nCause: health check failed\nHint: check DATABASE_URL\n\nRecent container logs:\n  booting app\n  connection refused", err.Error())
47	assert.ErrorIs(t, err, root)
48}
49
50func TestFormatDeployFailure_GenericFallback(t *testing.T) {
51	root := errors.New("boom")
52	err := formatDeployFailure(root)
53
54	require.Error(t, err)
55	assert.Equal(t, "failed to deploy: boom", err.Error())
56	assert.ErrorIs(t, err, root)
57}
58
59func TestFormatDeployFailure_SkipsEmptySanitizedLogsSection(t *testing.T) {
60	root := &domain.DeployFailureError{
61		Summary: "failed to deploy",
62		Cause:   "health check failed",
63		Logs:    []string{"\x1b[31m\x1b[0m", "\n\r\t"},
64	}
65	err := formatDeployFailure(root)
66
67	require.Error(t, err)
68	assert.Equal(t, "failed to deploy\nCause: health check failed", err.Error())
69	assert.ErrorIs(t, err, root)
70}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close