main 2aca1df

releases_test.go RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package usecase_test
4
5import (
6	"context"
7	"testing"
8
9	"bnema.dev/ermite/internal/domain"
10	"bnema.dev/ermite/internal/ports/mocks"
11	"github.com/stretchr/testify/mock"
12	"github.com/stretchr/testify/require"
13)
14
15func TestReleaseTagDeletionHook(t *testing.T) {
16	ctx := context.Background()
17	n := name(t, "tools")
18	f := newPushFixture(t)
19	trigger := mocks.NewReleaseTagTrigger(t)
20	f.pushes.WithReleases(trigger)
21	updates := []domain.RefUpdate{{Old: oidA, New: domain.ZeroOID, Ref: "refs/tags/v1"}}
22	expectPushMutation(t, f.meta, domain.Repo{Name: n}, nil)
23	f.git.EXPECT().DefaultBranch(ctx, n).Return("main", true, nil)
24	trigger.EXPECT().OnRefsMoved(ctx, n, updates).Return().Once()
25	f.bus.EXPECT().Publish(ctx, mock.Anything).Return().Once()
26	f.sched.EXPECT().Schedule(ctx, n).Return().Once()
27	require.NoError(t, f.pushes.Record(ctx, domain.Root(), n, updates))
28}
29
30func TestReleaseRepositoryDeletionHook(t *testing.T) {
31	for _, failed := range []bool{false, true} {
32		t.Run(map[bool]string{false: "deleted", true: "metadata failure"}[failed], func(t *testing.T) {
33			ctx := context.Background()
34			n := name(t, "tools")
35			f := newFixture(t)
36			cleaner := mocks.NewReleaseRepoCleaner(t)
37			f.repos.WithReleases(cleaner)
38			assets := []domain.ReleaseAsset{{ID: 42, Repo: n, ReleaseID: 1}}
39			f.meta.EXPECT().Get(ctx, n).Return(domain.Repo{Name: n}, nil)
40			f.git.EXPECT().Trash(ctx, n).Return(nil)
41			cleaner.EXPECT().AssetsOf(ctx, n).Return(assets, nil).Once()
42			if failed {
43				f.meta.EXPECT().Delete(ctx, n).Return(domain.ErrUnavailable).Once()
44				require.ErrorIs(t, f.repos.Delete(ctx, domain.Root(), n), domain.ErrUnavailable)
45			} else {
46				deleted := false
47				f.meta.EXPECT().Delete(ctx, n).Run(func(context.Context, domain.RepoName) { deleted = true }).Return(nil).Once()
48				cleaner.EXPECT().OnRepoDeleted(mock.Anything, n, assets).Run(func(ctx context.Context, _ domain.RepoName, _ []domain.ReleaseAsset) {
49					require.True(t, deleted)
50					require.Nil(t, ctx.Done())
51				}).Return().Once()
52				f.bus.EXPECT().Publish(ctx, mock.Anything).Return().Once()
53				require.NoError(t, f.repos.Delete(ctx, domain.Root(), n))
54			}
55		})
56	}
57}

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 2

Tags 43

↑↓ moveenter openesc close