v0.36.0 1fb2421

issue_links_test.go RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2package kvstore_test
3
4import (
5	"bnema.dev/ermite/internal/domain"
6	"context"
7	"github.com/stretchr/testify/assert"
8	"github.com/stretchr/testify/require"
9	"testing"
10)
11
12func TestIssueLinksReplace(t *testing.T) {
13	ctx := context.Background()
14	s, _, repo := repoWithMRs(t)
15	links := s.IssueLinks()
16	added, removed, err := links.ReplaceLinks(ctx, repo, 9, []int64{3, 2, 3}, []int64{2})
17	require.NoError(t, err)
18	assert.Equal(t, []domain.IssueLink{{Issue: 2, MergeRequest: 9, Closes: true}, {Issue: 3, MergeRequest: 9}}, added)
19	assert.Empty(t, removed)
20	got, err := links.LinksOfMergeRequest(ctx, repo, 9)
21	require.NoError(t, err)
22	assert.Equal(t, added, got)
23	added, removed, err = links.ReplaceLinks(ctx, repo, 9, []int64{2, 3}, []int64{2})
24	require.NoError(t, err)
25	assert.Empty(t, added)
26	assert.Empty(t, removed)
27	added, removed, err = links.ReplaceLinks(ctx, repo, 9, []int64{3, 4}, []int64{3})
28	require.NoError(t, err)
29	assert.Equal(t, []domain.IssueLink{{Issue: 3, MergeRequest: 9, Closes: true}, {Issue: 4, MergeRequest: 9}}, added)
30	assert.Equal(t, []domain.IssueLink{{Issue: 2, MergeRequest: 9, Closes: true}}, removed)
31	got, err = links.LinksOfIssue(ctx, repo, 2, 100)
32	require.NoError(t, err)
33	assert.Empty(t, got)
34	added, removed, err = links.ReplaceLinks(ctx, repo, 9, []int64{3}, nil)
35	require.NoError(t, err)
36	assert.Empty(t, added)
37	assert.Equal(t, []domain.IssueLink{{Issue: 3, MergeRequest: 9, Closes: true}, {Issue: 4, MergeRequest: 9}}, removed)
38	for _, mr := range []int64{12, 1, 5} {
39		_, _, err = links.ReplaceLinks(ctx, repo, mr, []int64{3}, nil)
40		require.NoError(t, err)
41	}
42	got, err = links.LinksOfIssue(ctx, repo, 3, 2)
43	require.NoError(t, err)
44	assert.Equal(t, []domain.IssueLink{{Issue: 3, MergeRequest: 1}, {Issue: 3, MergeRequest: 5}}, got)
45	require.NoError(t, s.Delete(ctx, repo))
46	assert.Zero(t, countKeys(t, s, "isref/"+repo.String()+"/"))
47	assert.Zero(t, countKeys(t, s, "mrref/"+repo.String()+"/"))
48	_, _, err = links.ReplaceLinks(ctx, repo, 9, []int64{2}, nil)
49	assert.ErrorIs(t, err, domain.ErrNotFound)
50}
51
52func TestIssueClosedByRoundTrip(t *testing.T) {
53	ctx := context.Background()
54	s, _, repo := repoWithMRs(t)
55	issue := newIssue(t, repo, "closed by merge")
56	issue.State = domain.IssueStateClosed
57	issue.ClosedByMergeRequest = 17
58	stored, err := s.Issues().Create(ctx, issue)
59	require.NoError(t, err)
60	assert.Equal(t, int64(17), stored.ClosedByMergeRequest)
61	stored.ClosedByMergeRequest = 0
62	require.NoError(t, s.Issues().Update(ctx, stored))
63	stored, err = s.Issues().Get(ctx, repo, stored.Number)
64	require.NoError(t, err)
65	assert.Zero(t, stored.ClosedByMergeRequest)
66}

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 4

Tags 45

↑↓ moveenter openesc close