v3.1.0 d676137

apps_findings_test.go RawHistoryFolder

1package cli
2
3import (
4	"bytes"
5	"context"
6	"strings"
7	"testing"
8
9	"github.com/stretchr/testify/assert"
10	"github.com/stretchr/testify/mock"
11	"github.com/stretchr/testify/require"
12
13	"github.com/bnema/gordon/internal/adapters/dto"
14	climocks "github.com/bnema/gordon/internal/adapters/in/cli/mocks"
15	"github.com/bnema/gordon/internal/adapters/in/cli/remote"
16)
17
18func TestRunAppsApply_DryRunOmitsEmptyRevisionAndRendersDiff(t *testing.T) {
19	plane := appPlane(t)
20	plane.EXPECT().ApplyApp(mock.Anything, mock.Anything).Return(&dto.AppApplyResponse{
21		App:    "blog",
22		Noop:   false,
23		Diff:   dto.AppDiffSection{Added: []string{"service.web"}},
24		Intent: "apply-7",
25	}, nil).Once()
26	var out bytes.Buffer
27	require.NoError(t, runAppsApply(context.Background(), plane, strings.NewReader(""), &out, &bytes.Buffer{},
28		writeManifest(t, "[app]\nname = \"blog\"\n"), true, false, false))
29	text := out.String()
30	assert.Contains(t, text, "Validated (dry-run) blog")
31	assert.NotContains(t, text, "()")
32	assert.Contains(t, text, "added:")
33	assert.Contains(t, text, "service.web")
34}
35
36func TestRunAppsApply_NoopOmitsEmptyRevision(t *testing.T) {
37	plane := appPlane(t)
38	plane.EXPECT().ApplyApp(mock.Anything, mock.Anything).
39		Return(&dto.AppApplyResponse{App: "blog", Noop: true}, nil).Once()
40	var out bytes.Buffer
41	require.NoError(t, runAppsApply(context.Background(), plane, strings.NewReader(""), &out, &bytes.Buffer{},
42		writeManifest(t, "x"), true, false, false))
43	assert.Contains(t, out.String(), "No changes for blog")
44	assert.NotContains(t, out.String(), "()")
45}
46
47func TestRunAppLogs_RejectsJSONWithFollow(t *testing.T) {
48	// The JSON/follow rejection happens before any read.
49	plane := appPlane(t)
50	err := runAppLogs(context.Background(), plane, &fakeAppLogReader{}, "blog", "web", true, 50, &bytes.Buffer{}, true)
51	require.Error(t, err)
52	assert.Contains(t, err.Error(), "--json")
53	assert.Contains(t, err.Error(), "--follow")
54}
55
56func TestAppLogRef_ZeroServicesAccurateError(t *testing.T) {
57	empty := &dto.AppShowResponse{App: "new"}
58	_, err := appLogRef(empty, "")
59	require.Error(t, err)
60	assert.Contains(t, err.Error(), "no active services")
61}
62
63func TestRunStatusCmd_AppsLabelAndSortedHelpers(t *testing.T) {
64	plane := climocks.NewMockControlPlane(t)
65	plane.EXPECT().GetStatus(mock.Anything).Return(&remote.Status{
66		Apps: 2, RegistryDomain: "g.example.com",
67		ContainerStatus: map[string]string{"zeta": "active", "alpha": "stopped"},
68	}, nil).Once()
69	var out bytes.Buffer
70	require.NoError(t, runStatusCmd(context.Background(), plane, &out))
71	text := out.String()
72	assert.Contains(t, text, "Apps:")
73	assert.NotContains(t, text, "Routes:")
74	assert.Less(t, strings.Index(text, "alpha"), strings.Index(text, "zeta"))
75}

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