detached 67508cc

test(usecase): run the issue moderation subtests in parallel

commit
67508cc051e5d547a6da8b5716f39abda92fc705
author
brice · · 2026-10-19 12:52 UTC
parent
f6f76c8
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
checks
7/8
1 file · +7 -0
M internal/usecase/issue_moderation_test.go +7 -0
@@ -85,6 +85,7 @@ func TestIssueModerationApprove(t *testing.T) {
8585 t.Parallel()
8686 ctx := context.Background()
8787 t.Run("publishes IssueOpened after the commit", func(t *testing.T) {
88+ t.Parallel()
8889 u := newModerationUnit(t, domain.IssuesPublic)
8990 issue := domain.Issue{Repo: u.repo.Name, Number: 7, State: domain.IssueStateOpen}
9091 u.pending.EXPECT().Approve(mock.Anything, u.repo.Name, u.id, now).Return(issue, nil).Once()
@@ -94,6 +95,7 @@ func TestIssueModerationApprove(t *testing.T) {
9495 assert.Equal(t, int64(7), got.Number)
9596 })
9697 t.Run("issues off hides the repository", func(t *testing.T) {
98+ t.Parallel()
9799 for _, mode := range []domain.IssuesMode{domain.IssuesOff, ""} {
98100 u := newModerationUnit(t, mode)
99101 _, err := u.mod.Approve(ctx, domain.Root(), u.repo.Name, u.id)
@@ -101,6 +103,7 @@ func TestIssueModerationApprove(t *testing.T) {
101103 }
102104 })
103105 t.Run("no event when the store refuses", func(t *testing.T) {
106+ t.Parallel()
104107 u := newModerationUnit(t, domain.IssuesOwner)
105108 u.pending.EXPECT().Approve(mock.Anything, u.repo.Name, u.id, now).Return(domain.Issue{}, domain.ErrNotFound).Once()
106109 _, err := u.mod.Approve(ctx, domain.Root(), u.repo.Name, u.id)
@@ -113,6 +116,7 @@ func TestIssueModerationReject(t *testing.T) {
113116 ctx := context.Background()
114117 hash := bytes.Repeat([]byte{3}, domain.IPHashLen)
115118 t.Run("with a ban", func(t *testing.T) {
119+ t.Parallel()
116120 u := newModerationUnit(t, domain.IssuesPublic)
117121 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{ID: u.id, Repo: u.repo.Name, IPHash: hash}, nil).Once()
118122 u.bans.EXPECT().Ban(mock.Anything, hash, now.Add(domain.BanDuration)).Return(nil).Once()
@@ -121,6 +125,7 @@ func TestIssueModerationReject(t *testing.T) {
121125 require.NoError(t, u.mod.Reject(ctx, domain.Owner(), u.repo.Name, u.id, true))
122126 })
123127 t.Run("without a ban", func(t *testing.T) {
128+ t.Parallel()
124129 u := newModerationUnit(t, domain.IssuesPublic)
125130 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{ID: u.id, IPHash: hash}, nil).Once()
126131 u.pending.EXPECT().Delete(mock.Anything, u.repo.Name, u.id).Return(nil).Once()
@@ -128,11 +133,13 @@ func TestIssueModerationReject(t *testing.T) {
128133 require.NoError(t, u.mod.Reject(ctx, domain.Owner(), u.repo.Name, u.id, false))
129134 })
130135 t.Run("unknown id", func(t *testing.T) {
136+ t.Parallel()
131137 u := newModerationUnit(t, domain.IssuesPublic)
132138 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{}, domain.ErrNotFound).Once()
133139 assert.ErrorIs(t, u.mod.Reject(ctx, domain.Owner(), u.repo.Name, u.id, true), domain.ErrNotFound)
134140 })
135141 t.Run("a failed ban keeps the pending issue", func(t *testing.T) {
142+ t.Parallel()
136143 u := newModerationUnit(t, domain.IssuesPublic)
137144 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{ID: u.id, IPHash: hash}, nil).Once()
138145 u.bans.EXPECT().Ban(mock.Anything, hash, mock.Anything).Return(assert.AnError).Once()
@@ -85,6 +85,7 @@ func TestIssueModerationApprove(t *testing.T) {
85 t.Parallel()85 t.Parallel()
86 ctx := context.Background()86 ctx := context.Background()
87 t.Run("publishes IssueOpened after the commit", func(t *testing.T) {87 t.Run("publishes IssueOpened after the commit", func(t *testing.T) {
88+ t.Parallel()
88 u := newModerationUnit(t, domain.IssuesPublic)89 u := newModerationUnit(t, domain.IssuesPublic)
89 issue := domain.Issue{Repo: u.repo.Name, Number: 7, State: domain.IssueStateOpen}90 issue := domain.Issue{Repo: u.repo.Name, Number: 7, State: domain.IssueStateOpen}
90 u.pending.EXPECT().Approve(mock.Anything, u.repo.Name, u.id, now).Return(issue, nil).Once()91 u.pending.EXPECT().Approve(mock.Anything, u.repo.Name, u.id, now).Return(issue, nil).Once()
@@ -94,6 +95,7 @@ func TestIssueModerationApprove(t *testing.T) {
94 assert.Equal(t, int64(7), got.Number)95 assert.Equal(t, int64(7), got.Number)
95 })96 })
96 t.Run("issues off hides the repository", func(t *testing.T) {97 t.Run("issues off hides the repository", func(t *testing.T) {
98+ t.Parallel()
97 for _, mode := range []domain.IssuesMode{domain.IssuesOff, ""} {99 for _, mode := range []domain.IssuesMode{domain.IssuesOff, ""} {
98 u := newModerationUnit(t, mode)100 u := newModerationUnit(t, mode)
99 _, err := u.mod.Approve(ctx, domain.Root(), u.repo.Name, u.id)101 _, err := u.mod.Approve(ctx, domain.Root(), u.repo.Name, u.id)
@@ -101,6 +103,7 @@ func TestIssueModerationApprove(t *testing.T) {
101 }103 }
102 })104 })
103 t.Run("no event when the store refuses", func(t *testing.T) {105 t.Run("no event when the store refuses", func(t *testing.T) {
106+ t.Parallel()
104 u := newModerationUnit(t, domain.IssuesOwner)107 u := newModerationUnit(t, domain.IssuesOwner)
105 u.pending.EXPECT().Approve(mock.Anything, u.repo.Name, u.id, now).Return(domain.Issue{}, domain.ErrNotFound).Once()108 u.pending.EXPECT().Approve(mock.Anything, u.repo.Name, u.id, now).Return(domain.Issue{}, domain.ErrNotFound).Once()
106 _, err := u.mod.Approve(ctx, domain.Root(), u.repo.Name, u.id)109 _, err := u.mod.Approve(ctx, domain.Root(), u.repo.Name, u.id)
@@ -113,6 +116,7 @@ func TestIssueModerationReject(t *testing.T) {
113 ctx := context.Background()116 ctx := context.Background()
114 hash := bytes.Repeat([]byte{3}, domain.IPHashLen)117 hash := bytes.Repeat([]byte{3}, domain.IPHashLen)
115 t.Run("with a ban", func(t *testing.T) {118 t.Run("with a ban", func(t *testing.T) {
119+ t.Parallel()
116 u := newModerationUnit(t, domain.IssuesPublic)120 u := newModerationUnit(t, domain.IssuesPublic)
117 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{ID: u.id, Repo: u.repo.Name, IPHash: hash}, nil).Once()121 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{ID: u.id, Repo: u.repo.Name, IPHash: hash}, nil).Once()
118 u.bans.EXPECT().Ban(mock.Anything, hash, now.Add(domain.BanDuration)).Return(nil).Once()122 u.bans.EXPECT().Ban(mock.Anything, hash, now.Add(domain.BanDuration)).Return(nil).Once()
@@ -121,6 +125,7 @@ func TestIssueModerationReject(t *testing.T) {
121 require.NoError(t, u.mod.Reject(ctx, domain.Owner(), u.repo.Name, u.id, true))125 require.NoError(t, u.mod.Reject(ctx, domain.Owner(), u.repo.Name, u.id, true))
122 })126 })
123 t.Run("without a ban", func(t *testing.T) {127 t.Run("without a ban", func(t *testing.T) {
128+ t.Parallel()
124 u := newModerationUnit(t, domain.IssuesPublic)129 u := newModerationUnit(t, domain.IssuesPublic)
125 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{ID: u.id, IPHash: hash}, nil).Once()130 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{ID: u.id, IPHash: hash}, nil).Once()
126 u.pending.EXPECT().Delete(mock.Anything, u.repo.Name, u.id).Return(nil).Once()131 u.pending.EXPECT().Delete(mock.Anything, u.repo.Name, u.id).Return(nil).Once()
@@ -128,11 +133,13 @@ func TestIssueModerationReject(t *testing.T) {
128 require.NoError(t, u.mod.Reject(ctx, domain.Owner(), u.repo.Name, u.id, false))133 require.NoError(t, u.mod.Reject(ctx, domain.Owner(), u.repo.Name, u.id, false))
129 })134 })
130 t.Run("unknown id", func(t *testing.T) {135 t.Run("unknown id", func(t *testing.T) {
136+ t.Parallel()
131 u := newModerationUnit(t, domain.IssuesPublic)137 u := newModerationUnit(t, domain.IssuesPublic)
132 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{}, domain.ErrNotFound).Once()138 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{}, domain.ErrNotFound).Once()
133 assert.ErrorIs(t, u.mod.Reject(ctx, domain.Owner(), u.repo.Name, u.id, true), domain.ErrNotFound)139 assert.ErrorIs(t, u.mod.Reject(ctx, domain.Owner(), u.repo.Name, u.id, true), domain.ErrNotFound)
134 })140 })
135 t.Run("a failed ban keeps the pending issue", func(t *testing.T) {141 t.Run("a failed ban keeps the pending issue", func(t *testing.T) {
142+ t.Parallel()
136 u := newModerationUnit(t, domain.IssuesPublic)143 u := newModerationUnit(t, domain.IssuesPublic)
137 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{ID: u.id, IPHash: hash}, nil).Once()144 u.pending.EXPECT().Get(mock.Anything, u.repo.Name, u.id).Return(domain.PendingIssue{ID: u.id, IPHash: hash}, nil).Once()
138 u.bans.EXPECT().Ban(mock.Anything, hash, mock.Anything).Return(assert.AnError).Once()145 u.bans.EXPECT().Ban(mock.Anything, hash, mock.Anything).Return(assert.AnError).Once()

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