feat(ports): add the pending issue, key, ban, submission limiter and moderation ports
- commit
- dca1fe7207676f6b953b0cbaa11e604ef4b2c540
- author
- brice · · 2026-10-19 06:54 UTC
- parent
- 784ea9f
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
8 files · +1330 -1
M internal/ports/dto.go +19 -1
| @@ -218,6 +218,21 @@ type IssuePage struct { | |||
| 218 | 218 | NextPageToken string | |
| 219 | 219 | } | |
| 220 | 220 | ||
| 221 | + | // ListPendingParams selects a page of pending issues. | |
| 222 | + | type ListPendingParams struct { | |
| 223 | + | // PageSize is the page size; the use case applies the default and the | |
| 224 | + | // maximum, a store takes it as is (0: every one). | |
| 225 | + | PageSize int | |
| 226 | + | // PageToken is the NextPageToken of the previous page. | |
| 227 | + | PageToken string | |
| 228 | + | } | |
| 229 | + | ||
| 230 | + | // PendingIssuePage is a page of pending issues, oldest first. | |
| 231 | + | type PendingIssuePage struct { | |
| 232 | + | Issues []domain.PendingIssue | |
| 233 | + | NextPageToken string | |
| 234 | + | } | |
| 235 | + | ||
| 221 | 236 | // CreateIssueParams describes the issue to open. | |
| 222 | 237 | type CreateIssueParams struct { | |
| 223 | 238 | Title string | |
| @@ -316,7 +331,7 @@ type InboxMergeRequest struct { | |||
| 316 | 331 | ||
| 317 | 332 | // InboxCounts are the numbers of open items across every repository, whatever | |
| 318 | 333 | // the filter. | |
| 319 | - | type InboxCounts struct{ MergeRequests, Issues int } | |
| 334 | + | type InboxCounts struct{ MergeRequests, Issues, Pending int } | |
| 320 | 335 | ||
| 321 | 336 | // InboxOverview is what the owner has to look at across every repository: the | |
| 322 | 337 | // open merge requests and the open issues, most recently updated first. A | |
| @@ -327,6 +342,9 @@ type InboxOverview struct { | |||
| 327 | 342 | // every repository when there is no filter. Counts always counts all. | |
| 328 | 343 | MergeRequests []InboxMergeRequest | |
| 329 | 344 | Issues []domain.Issue | |
| 345 | + | // Pending are the issues awaiting moderation, in every repository | |
| 346 | + | // whatever the filter, oldest first. At most domain.MaxPendingIssues. | |
| 347 | + | Pending []domain.PendingIssue | |
| 330 | 348 | // Repos are the repositories that have at least one open item, by name, | |
| 331 | 349 | // whatever the filter: they feed the filter itself. | |
| 332 | 350 | Repos []domain.RepoName | |
| @@ -218,6 +218,21 @@ type IssuePage struct { | |||||
| 218 | NextPageToken string | 218 | NextPageToken string | ||
| 219 | } | 219 | } | ||
| 220 | 220 | ||||
| 221 | + | // ListPendingParams selects a page of pending issues. | |||
| 222 | + | type ListPendingParams struct { | |||
| 223 | + | // PageSize is the page size; the use case applies the default and the | |||
| 224 | + | // maximum, a store takes it as is (0: every one). | |||
| 225 | + | PageSize int | |||
| 226 | + | // PageToken is the NextPageToken of the previous page. | |||
| 227 | + | PageToken string | |||
| 228 | + | } | |||
| 229 | + | ||||
| 230 | + | // PendingIssuePage is a page of pending issues, oldest first. | |||
| 231 | + | type PendingIssuePage struct { | |||
| 232 | + | Issues []domain.PendingIssue | |||
| 233 | + | NextPageToken string | |||
| 234 | + | } | |||
| 235 | + | ||||
| 221 | // CreateIssueParams describes the issue to open. | 236 | // CreateIssueParams describes the issue to open. | ||
| 222 | type CreateIssueParams struct { | 237 | type CreateIssueParams struct { | ||
| 223 | Title string | 238 | Title string | ||
| @@ -316,7 +331,7 @@ type InboxMergeRequest struct { | |||||
| 316 | 331 | ||||
| 317 | // InboxCounts are the numbers of open items across every repository, whatever | 332 | // InboxCounts are the numbers of open items across every repository, whatever | ||
| 318 | // the filter. | 333 | // the filter. | ||
| 319 | - | type InboxCounts struct{ MergeRequests, Issues int } | 334 | + | type InboxCounts struct{ MergeRequests, Issues, Pending int } |
| 320 | 335 | ||||
| 321 | // InboxOverview is what the owner has to look at across every repository: the | 336 | // InboxOverview is what the owner has to look at across every repository: the | ||
| 322 | // open merge requests and the open issues, most recently updated first. A | 337 | // open merge requests and the open issues, most recently updated first. A | ||
| @@ -327,6 +342,9 @@ type InboxOverview struct { | |||||
| 327 | // every repository when there is no filter. Counts always counts all. | 342 | // every repository when there is no filter. Counts always counts all. | ||
| 328 | MergeRequests []InboxMergeRequest | 343 | MergeRequests []InboxMergeRequest | ||
| 329 | Issues []domain.Issue | 344 | Issues []domain.Issue | ||
| 345 | + | // Pending are the issues awaiting moderation, in every repository | |||
| 346 | + | // whatever the filter, oldest first. At most domain.MaxPendingIssues. | |||
| 347 | + | Pending []domain.PendingIssue | |||
| 330 | // Repos are the repositories that have at least one open item, by name, | 348 | // Repos are the repositories that have at least one open item, by name, | ||
| 331 | // whatever the filter: they feed the filter itself. | 349 | // whatever the filter: they feed the filter itself. | ||
| 332 | Repos []domain.RepoName | 350 | Repos []domain.RepoName | ||
A internal/ports/mocks/IssueBanStore.go +183 -0
| @@ -0,0 +1,183 @@ | |||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |
| 2 | + | // github.com/vektra/mockery | |
| 3 | + | // template: testify | |
| 4 | + | ||
| 5 | + | package mocks | |
| 6 | + | ||
| 7 | + | import ( | |
| 8 | + | "context" | |
| 9 | + | "time" | |
| 10 | + | ||
| 11 | + | mock "github.com/stretchr/testify/mock" | |
| 12 | + | ) | |
| 13 | + | ||
| 14 | + | // NewIssueBanStore creates a new instance of IssueBanStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |
| 15 | + | // The first argument is typically a *testing.T value. | |
| 16 | + | func NewIssueBanStore(t interface { | |
| 17 | + | mock.TestingT | |
| 18 | + | Cleanup(func()) | |
| 19 | + | }) *IssueBanStore { | |
| 20 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 21 | + | helper.Helper() | |
| 22 | + | } | |
| 23 | + | ||
| 24 | + | mock := &IssueBanStore{} | |
| 25 | + | mock.Mock.Test(t) | |
| 26 | + | ||
| 27 | + | t.Cleanup(func() { | |
| 28 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 29 | + | helper.Helper() | |
| 30 | + | } | |
| 31 | + | mock.AssertExpectations(t) | |
| 32 | + | }) | |
| 33 | + | ||
| 34 | + | return mock | |
| 35 | + | } | |
| 36 | + | ||
| 37 | + | // IssueBanStore is an autogenerated mock type for the IssueBanStore type | |
| 38 | + | type IssueBanStore struct { | |
| 39 | + | mock.Mock | |
| 40 | + | } | |
| 41 | + | ||
| 42 | + | type IssueBanStore_Expecter struct { | |
| 43 | + | mock *mock.Mock | |
| 44 | + | } | |
| 45 | + | ||
| 46 | + | func (_m *IssueBanStore) EXPECT() *IssueBanStore_Expecter { | |
| 47 | + | return &IssueBanStore_Expecter{mock: &_m.Mock} | |
| 48 | + | } | |
| 49 | + | ||
| 50 | + | // Ban provides a mock function for the type IssueBanStore | |
| 51 | + | func (_mock *IssueBanStore) Ban(ctx context.Context, hash []byte, until time.Time) error { | |
| 52 | + | ret := _mock.Called(ctx, hash, until) | |
| 53 | + | ||
| 54 | + | if len(ret) == 0 { | |
| 55 | + | panic("no return value specified for Ban") | |
| 56 | + | } | |
| 57 | + | ||
| 58 | + | var r0 error | |
| 59 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, []byte, time.Time) error); ok { | |
| 60 | + | r0 = returnFunc(ctx, hash, until) | |
| 61 | + | } else { | |
| 62 | + | r0 = ret.Error(0) | |
| 63 | + | } | |
| 64 | + | return r0 | |
| 65 | + | } | |
| 66 | + | ||
| 67 | + | // IssueBanStore_Ban_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Ban' | |
| 68 | + | type IssueBanStore_Ban_Call struct { | |
| 69 | + | *mock.Call | |
| 70 | + | } | |
| 71 | + | ||
| 72 | + | // Ban is a helper method to define mock.On call | |
| 73 | + | // - ctx context.Context | |
| 74 | + | // - hash []byte | |
| 75 | + | // - until time.Time | |
| 76 | + | func (_e *IssueBanStore_Expecter) Ban(ctx any, hash any, until any) *IssueBanStore_Ban_Call { | |
| 77 | + | return &IssueBanStore_Ban_Call{Call: _e.mock.On("Ban", ctx, hash, until)} | |
| 78 | + | } | |
| 79 | + | ||
| 80 | + | func (_c *IssueBanStore_Ban_Call) Run(run func(ctx context.Context, hash []byte, until time.Time)) *IssueBanStore_Ban_Call { | |
| 81 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 82 | + | var arg0 context.Context | |
| 83 | + | if args[0] != nil { | |
| 84 | + | arg0 = args[0].(context.Context) | |
| 85 | + | } | |
| 86 | + | var arg1 []byte | |
| 87 | + | if args[1] != nil { | |
| 88 | + | arg1 = args[1].([]byte) | |
| 89 | + | } | |
| 90 | + | var arg2 time.Time | |
| 91 | + | if args[2] != nil { | |
| 92 | + | arg2 = args[2].(time.Time) | |
| 93 | + | } | |
| 94 | + | run( | |
| 95 | + | arg0, | |
| 96 | + | arg1, | |
| 97 | + | arg2, | |
| 98 | + | ) | |
| 99 | + | }) | |
| 100 | + | return _c | |
| 101 | + | } | |
| 102 | + | ||
| 103 | + | func (_c *IssueBanStore_Ban_Call) Return(err error) *IssueBanStore_Ban_Call { | |
| 104 | + | _c.Call.Return(err) | |
| 105 | + | return _c | |
| 106 | + | } | |
| 107 | + | ||
| 108 | + | func (_c *IssueBanStore_Ban_Call) RunAndReturn(run func(ctx context.Context, hash []byte, until time.Time) error) *IssueBanStore_Ban_Call { | |
| 109 | + | _c.Call.Return(run) | |
| 110 | + | return _c | |
| 111 | + | } | |
| 112 | + | ||
| 113 | + | // Banned provides a mock function for the type IssueBanStore | |
| 114 | + | func (_mock *IssueBanStore) Banned(ctx context.Context, hash []byte, now time.Time) (bool, error) { | |
| 115 | + | ret := _mock.Called(ctx, hash, now) | |
| 116 | + | ||
| 117 | + | if len(ret) == 0 { | |
| 118 | + | panic("no return value specified for Banned") | |
| 119 | + | } | |
| 120 | + | ||
| 121 | + | var r0 bool | |
| 122 | + | var r1 error | |
| 123 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, []byte, time.Time) (bool, error)); ok { | |
| 124 | + | return returnFunc(ctx, hash, now) | |
| 125 | + | } | |
| 126 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, []byte, time.Time) bool); ok { | |
| 127 | + | r0 = returnFunc(ctx, hash, now) | |
| 128 | + | } else { | |
| 129 | + | r0 = ret.Get(0).(bool) | |
| 130 | + | } | |
| 131 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, []byte, time.Time) error); ok { | |
| 132 | + | r1 = returnFunc(ctx, hash, now) | |
| 133 | + | } else { | |
| 134 | + | r1 = ret.Error(1) | |
| 135 | + | } | |
| 136 | + | return r0, r1 | |
| 137 | + | } | |
| 138 | + | ||
| 139 | + | // IssueBanStore_Banned_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Banned' | |
| 140 | + | type IssueBanStore_Banned_Call struct { | |
| 141 | + | *mock.Call | |
| 142 | + | } | |
| 143 | + | ||
| 144 | + | // Banned is a helper method to define mock.On call | |
| 145 | + | // - ctx context.Context | |
| 146 | + | // - hash []byte | |
| 147 | + | // - now time.Time | |
| 148 | + | func (_e *IssueBanStore_Expecter) Banned(ctx any, hash any, now any) *IssueBanStore_Banned_Call { | |
| 149 | + | return &IssueBanStore_Banned_Call{Call: _e.mock.On("Banned", ctx, hash, now)} | |
| 150 | + | } | |
| 151 | + | ||
| 152 | + | func (_c *IssueBanStore_Banned_Call) Run(run func(ctx context.Context, hash []byte, now time.Time)) *IssueBanStore_Banned_Call { | |
| 153 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 154 | + | var arg0 context.Context | |
| 155 | + | if args[0] != nil { | |
| 156 | + | arg0 = args[0].(context.Context) | |
| 157 | + | } | |
| 158 | + | var arg1 []byte | |
| 159 | + | if args[1] != nil { | |
| 160 | + | arg1 = args[1].([]byte) | |
| 161 | + | } | |
| 162 | + | var arg2 time.Time | |
| 163 | + | if args[2] != nil { | |
| 164 | + | arg2 = args[2].(time.Time) | |
| 165 | + | } | |
| 166 | + | run( | |
| 167 | + | arg0, | |
| 168 | + | arg1, | |
| 169 | + | arg2, | |
| 170 | + | ) | |
| 171 | + | }) | |
| 172 | + | return _c | |
| 173 | + | } | |
| 174 | + | ||
| 175 | + | func (_c *IssueBanStore_Banned_Call) Return(b bool, err error) *IssueBanStore_Banned_Call { | |
| 176 | + | _c.Call.Return(b, err) | |
| 177 | + | return _c | |
| 178 | + | } | |
| 179 | + | ||
| 180 | + | func (_c *IssueBanStore_Banned_Call) RunAndReturn(run func(ctx context.Context, hash []byte, now time.Time) (bool, error)) *IssueBanStore_Banned_Call { | |
| 181 | + | _c.Call.Return(run) | |
| 182 | + | return _c | |
| 183 | + | } | |
| @@ -0,0 +1,183 @@ | |||||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |||
| 2 | + | // github.com/vektra/mockery | |||
| 3 | + | // template: testify | |||
| 4 | + | ||||
| 5 | + | package mocks | |||
| 6 | + | ||||
| 7 | + | import ( | |||
| 8 | + | "context" | |||
| 9 | + | "time" | |||
| 10 | + | ||||
| 11 | + | mock "github.com/stretchr/testify/mock" | |||
| 12 | + | ) | |||
| 13 | + | ||||
| 14 | + | // NewIssueBanStore creates a new instance of IssueBanStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |||
| 15 | + | // The first argument is typically a *testing.T value. | |||
| 16 | + | func NewIssueBanStore(t interface { | |||
| 17 | + | mock.TestingT | |||
| 18 | + | Cleanup(func()) | |||
| 19 | + | }) *IssueBanStore { | |||
| 20 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 21 | + | helper.Helper() | |||
| 22 | + | } | |||
| 23 | + | ||||
| 24 | + | mock := &IssueBanStore{} | |||
| 25 | + | mock.Mock.Test(t) | |||
| 26 | + | ||||
| 27 | + | t.Cleanup(func() { | |||
| 28 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 29 | + | helper.Helper() | |||
| 30 | + | } | |||
| 31 | + | mock.AssertExpectations(t) | |||
| 32 | + | }) | |||
| 33 | + | ||||
| 34 | + | return mock | |||
| 35 | + | } | |||
| 36 | + | ||||
| 37 | + | // IssueBanStore is an autogenerated mock type for the IssueBanStore type | |||
| 38 | + | type IssueBanStore struct { | |||
| 39 | + | mock.Mock | |||
| 40 | + | } | |||
| 41 | + | ||||
| 42 | + | type IssueBanStore_Expecter struct { | |||
| 43 | + | mock *mock.Mock | |||
| 44 | + | } | |||
| 45 | + | ||||
| 46 | + | func (_m *IssueBanStore) EXPECT() *IssueBanStore_Expecter { | |||
| 47 | + | return &IssueBanStore_Expecter{mock: &_m.Mock} | |||
| 48 | + | } | |||
| 49 | + | ||||
| 50 | + | // Ban provides a mock function for the type IssueBanStore | |||
| 51 | + | func (_mock *IssueBanStore) Ban(ctx context.Context, hash []byte, until time.Time) error { | |||
| 52 | + | ret := _mock.Called(ctx, hash, until) | |||
| 53 | + | ||||
| 54 | + | if len(ret) == 0 { | |||
| 55 | + | panic("no return value specified for Ban") | |||
| 56 | + | } | |||
| 57 | + | ||||
| 58 | + | var r0 error | |||
| 59 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, []byte, time.Time) error); ok { | |||
| 60 | + | r0 = returnFunc(ctx, hash, until) | |||
| 61 | + | } else { | |||
| 62 | + | r0 = ret.Error(0) | |||
| 63 | + | } | |||
| 64 | + | return r0 | |||
| 65 | + | } | |||
| 66 | + | ||||
| 67 | + | // IssueBanStore_Ban_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Ban' | |||
| 68 | + | type IssueBanStore_Ban_Call struct { | |||
| 69 | + | *mock.Call | |||
| 70 | + | } | |||
| 71 | + | ||||
| 72 | + | // Ban is a helper method to define mock.On call | |||
| 73 | + | // - ctx context.Context | |||
| 74 | + | // - hash []byte | |||
| 75 | + | // - until time.Time | |||
| 76 | + | func (_e *IssueBanStore_Expecter) Ban(ctx any, hash any, until any) *IssueBanStore_Ban_Call { | |||
| 77 | + | return &IssueBanStore_Ban_Call{Call: _e.mock.On("Ban", ctx, hash, until)} | |||
| 78 | + | } | |||
| 79 | + | ||||
| 80 | + | func (_c *IssueBanStore_Ban_Call) Run(run func(ctx context.Context, hash []byte, until time.Time)) *IssueBanStore_Ban_Call { | |||
| 81 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 82 | + | var arg0 context.Context | |||
| 83 | + | if args[0] != nil { | |||
| 84 | + | arg0 = args[0].(context.Context) | |||
| 85 | + | } | |||
| 86 | + | var arg1 []byte | |||
| 87 | + | if args[1] != nil { | |||
| 88 | + | arg1 = args[1].([]byte) | |||
| 89 | + | } | |||
| 90 | + | var arg2 time.Time | |||
| 91 | + | if args[2] != nil { | |||
| 92 | + | arg2 = args[2].(time.Time) | |||
| 93 | + | } | |||
| 94 | + | run( | |||
| 95 | + | arg0, | |||
| 96 | + | arg1, | |||
| 97 | + | arg2, | |||
| 98 | + | ) | |||
| 99 | + | }) | |||
| 100 | + | return _c | |||
| 101 | + | } | |||
| 102 | + | ||||
| 103 | + | func (_c *IssueBanStore_Ban_Call) Return(err error) *IssueBanStore_Ban_Call { | |||
| 104 | + | _c.Call.Return(err) | |||
| 105 | + | return _c | |||
| 106 | + | } | |||
| 107 | + | ||||
| 108 | + | func (_c *IssueBanStore_Ban_Call) RunAndReturn(run func(ctx context.Context, hash []byte, until time.Time) error) *IssueBanStore_Ban_Call { | |||
| 109 | + | _c.Call.Return(run) | |||
| 110 | + | return _c | |||
| 111 | + | } | |||
| 112 | + | ||||
| 113 | + | // Banned provides a mock function for the type IssueBanStore | |||
| 114 | + | func (_mock *IssueBanStore) Banned(ctx context.Context, hash []byte, now time.Time) (bool, error) { | |||
| 115 | + | ret := _mock.Called(ctx, hash, now) | |||
| 116 | + | ||||
| 117 | + | if len(ret) == 0 { | |||
| 118 | + | panic("no return value specified for Banned") | |||
| 119 | + | } | |||
| 120 | + | ||||
| 121 | + | var r0 bool | |||
| 122 | + | var r1 error | |||
| 123 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, []byte, time.Time) (bool, error)); ok { | |||
| 124 | + | return returnFunc(ctx, hash, now) | |||
| 125 | + | } | |||
| 126 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, []byte, time.Time) bool); ok { | |||
| 127 | + | r0 = returnFunc(ctx, hash, now) | |||
| 128 | + | } else { | |||
| 129 | + | r0 = ret.Get(0).(bool) | |||
| 130 | + | } | |||
| 131 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, []byte, time.Time) error); ok { | |||
| 132 | + | r1 = returnFunc(ctx, hash, now) | |||
| 133 | + | } else { | |||
| 134 | + | r1 = ret.Error(1) | |||
| 135 | + | } | |||
| 136 | + | return r0, r1 | |||
| 137 | + | } | |||
| 138 | + | ||||
| 139 | + | // IssueBanStore_Banned_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Banned' | |||
| 140 | + | type IssueBanStore_Banned_Call struct { | |||
| 141 | + | *mock.Call | |||
| 142 | + | } | |||
| 143 | + | ||||
| 144 | + | // Banned is a helper method to define mock.On call | |||
| 145 | + | // - ctx context.Context | |||
| 146 | + | // - hash []byte | |||
| 147 | + | // - now time.Time | |||
| 148 | + | func (_e *IssueBanStore_Expecter) Banned(ctx any, hash any, now any) *IssueBanStore_Banned_Call { | |||
| 149 | + | return &IssueBanStore_Banned_Call{Call: _e.mock.On("Banned", ctx, hash, now)} | |||
| 150 | + | } | |||
| 151 | + | ||||
| 152 | + | func (_c *IssueBanStore_Banned_Call) Run(run func(ctx context.Context, hash []byte, now time.Time)) *IssueBanStore_Banned_Call { | |||
| 153 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 154 | + | var arg0 context.Context | |||
| 155 | + | if args[0] != nil { | |||
| 156 | + | arg0 = args[0].(context.Context) | |||
| 157 | + | } | |||
| 158 | + | var arg1 []byte | |||
| 159 | + | if args[1] != nil { | |||
| 160 | + | arg1 = args[1].([]byte) | |||
| 161 | + | } | |||
| 162 | + | var arg2 time.Time | |||
| 163 | + | if args[2] != nil { | |||
| 164 | + | arg2 = args[2].(time.Time) | |||
| 165 | + | } | |||
| 166 | + | run( | |||
| 167 | + | arg0, | |||
| 168 | + | arg1, | |||
| 169 | + | arg2, | |||
| 170 | + | ) | |||
| 171 | + | }) | |||
| 172 | + | return _c | |||
| 173 | + | } | |||
| 174 | + | ||||
| 175 | + | func (_c *IssueBanStore_Banned_Call) Return(b bool, err error) *IssueBanStore_Banned_Call { | |||
| 176 | + | _c.Call.Return(b, err) | |||
| 177 | + | return _c | |||
| 178 | + | } | |||
| 179 | + | ||||
| 180 | + | func (_c *IssueBanStore_Banned_Call) RunAndReturn(run func(ctx context.Context, hash []byte, now time.Time) (bool, error)) *IssueBanStore_Banned_Call { | |||
| 181 | + | _c.Call.Return(run) | |||
| 182 | + | return _c | |||
| 183 | + | } | |||
A internal/ports/mocks/IssueKeyStore.go +109 -0
| @@ -0,0 +1,109 @@ | |||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |
| 2 | + | // github.com/vektra/mockery | |
| 3 | + | // template: testify | |
| 4 | + | ||
| 5 | + | package mocks | |
| 6 | + | ||
| 7 | + | import ( | |
| 8 | + | "context" | |
| 9 | + | ||
| 10 | + | mock "github.com/stretchr/testify/mock" | |
| 11 | + | ) | |
| 12 | + | ||
| 13 | + | // NewIssueKeyStore creates a new instance of IssueKeyStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |
| 14 | + | // The first argument is typically a *testing.T value. | |
| 15 | + | func NewIssueKeyStore(t interface { | |
| 16 | + | mock.TestingT | |
| 17 | + | Cleanup(func()) | |
| 18 | + | }) *IssueKeyStore { | |
| 19 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 20 | + | helper.Helper() | |
| 21 | + | } | |
| 22 | + | ||
| 23 | + | mock := &IssueKeyStore{} | |
| 24 | + | mock.Mock.Test(t) | |
| 25 | + | ||
| 26 | + | t.Cleanup(func() { | |
| 27 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 28 | + | helper.Helper() | |
| 29 | + | } | |
| 30 | + | mock.AssertExpectations(t) | |
| 31 | + | }) | |
| 32 | + | ||
| 33 | + | return mock | |
| 34 | + | } | |
| 35 | + | ||
| 36 | + | // IssueKeyStore is an autogenerated mock type for the IssueKeyStore type | |
| 37 | + | type IssueKeyStore struct { | |
| 38 | + | mock.Mock | |
| 39 | + | } | |
| 40 | + | ||
| 41 | + | type IssueKeyStore_Expecter struct { | |
| 42 | + | mock *mock.Mock | |
| 43 | + | } | |
| 44 | + | ||
| 45 | + | func (_m *IssueKeyStore) EXPECT() *IssueKeyStore_Expecter { | |
| 46 | + | return &IssueKeyStore_Expecter{mock: &_m.Mock} | |
| 47 | + | } | |
| 48 | + | ||
| 49 | + | // Key provides a mock function for the type IssueKeyStore | |
| 50 | + | func (_mock *IssueKeyStore) Key(ctx context.Context) ([]byte, error) { | |
| 51 | + | ret := _mock.Called(ctx) | |
| 52 | + | ||
| 53 | + | if len(ret) == 0 { | |
| 54 | + | panic("no return value specified for Key") | |
| 55 | + | } | |
| 56 | + | ||
| 57 | + | var r0 []byte | |
| 58 | + | var r1 error | |
| 59 | + | if returnFunc, ok := ret.Get(0).(func(context.Context) ([]byte, error)); ok { | |
| 60 | + | return returnFunc(ctx) | |
| 61 | + | } | |
| 62 | + | if returnFunc, ok := ret.Get(0).(func(context.Context) []byte); ok { | |
| 63 | + | r0 = returnFunc(ctx) | |
| 64 | + | } else { | |
| 65 | + | if ret.Get(0) != nil { | |
| 66 | + | r0 = ret.Get(0).([]byte) | |
| 67 | + | } | |
| 68 | + | } | |
| 69 | + | if returnFunc, ok := ret.Get(1).(func(context.Context) error); ok { | |
| 70 | + | r1 = returnFunc(ctx) | |
| 71 | + | } else { | |
| 72 | + | r1 = ret.Error(1) | |
| 73 | + | } | |
| 74 | + | return r0, r1 | |
| 75 | + | } | |
| 76 | + | ||
| 77 | + | // IssueKeyStore_Key_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Key' | |
| 78 | + | type IssueKeyStore_Key_Call struct { | |
| 79 | + | *mock.Call | |
| 80 | + | } | |
| 81 | + | ||
| 82 | + | // Key is a helper method to define mock.On call | |
| 83 | + | // - ctx context.Context | |
| 84 | + | func (_e *IssueKeyStore_Expecter) Key(ctx any) *IssueKeyStore_Key_Call { | |
| 85 | + | return &IssueKeyStore_Key_Call{Call: _e.mock.On("Key", ctx)} | |
| 86 | + | } | |
| 87 | + | ||
| 88 | + | func (_c *IssueKeyStore_Key_Call) Run(run func(ctx context.Context)) *IssueKeyStore_Key_Call { | |
| 89 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 90 | + | var arg0 context.Context | |
| 91 | + | if args[0] != nil { | |
| 92 | + | arg0 = args[0].(context.Context) | |
| 93 | + | } | |
| 94 | + | run( | |
| 95 | + | arg0, | |
| 96 | + | ) | |
| 97 | + | }) | |
| 98 | + | return _c | |
| 99 | + | } | |
| 100 | + | ||
| 101 | + | func (_c *IssueKeyStore_Key_Call) Return(bytes []byte, err error) *IssueKeyStore_Key_Call { | |
| 102 | + | _c.Call.Return(bytes, err) | |
| 103 | + | return _c | |
| 104 | + | } | |
| 105 | + | ||
| 106 | + | func (_c *IssueKeyStore_Key_Call) RunAndReturn(run func(ctx context.Context) ([]byte, error)) *IssueKeyStore_Key_Call { | |
| 107 | + | _c.Call.Return(run) | |
| 108 | + | return _c | |
| 109 | + | } | |
| @@ -0,0 +1,109 @@ | |||||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |||
| 2 | + | // github.com/vektra/mockery | |||
| 3 | + | // template: testify | |||
| 4 | + | ||||
| 5 | + | package mocks | |||
| 6 | + | ||||
| 7 | + | import ( | |||
| 8 | + | "context" | |||
| 9 | + | ||||
| 10 | + | mock "github.com/stretchr/testify/mock" | |||
| 11 | + | ) | |||
| 12 | + | ||||
| 13 | + | // NewIssueKeyStore creates a new instance of IssueKeyStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |||
| 14 | + | // The first argument is typically a *testing.T value. | |||
| 15 | + | func NewIssueKeyStore(t interface { | |||
| 16 | + | mock.TestingT | |||
| 17 | + | Cleanup(func()) | |||
| 18 | + | }) *IssueKeyStore { | |||
| 19 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 20 | + | helper.Helper() | |||
| 21 | + | } | |||
| 22 | + | ||||
| 23 | + | mock := &IssueKeyStore{} | |||
| 24 | + | mock.Mock.Test(t) | |||
| 25 | + | ||||
| 26 | + | t.Cleanup(func() { | |||
| 27 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 28 | + | helper.Helper() | |||
| 29 | + | } | |||
| 30 | + | mock.AssertExpectations(t) | |||
| 31 | + | }) | |||
| 32 | + | ||||
| 33 | + | return mock | |||
| 34 | + | } | |||
| 35 | + | ||||
| 36 | + | // IssueKeyStore is an autogenerated mock type for the IssueKeyStore type | |||
| 37 | + | type IssueKeyStore struct { | |||
| 38 | + | mock.Mock | |||
| 39 | + | } | |||
| 40 | + | ||||
| 41 | + | type IssueKeyStore_Expecter struct { | |||
| 42 | + | mock *mock.Mock | |||
| 43 | + | } | |||
| 44 | + | ||||
| 45 | + | func (_m *IssueKeyStore) EXPECT() *IssueKeyStore_Expecter { | |||
| 46 | + | return &IssueKeyStore_Expecter{mock: &_m.Mock} | |||
| 47 | + | } | |||
| 48 | + | ||||
| 49 | + | // Key provides a mock function for the type IssueKeyStore | |||
| 50 | + | func (_mock *IssueKeyStore) Key(ctx context.Context) ([]byte, error) { | |||
| 51 | + | ret := _mock.Called(ctx) | |||
| 52 | + | ||||
| 53 | + | if len(ret) == 0 { | |||
| 54 | + | panic("no return value specified for Key") | |||
| 55 | + | } | |||
| 56 | + | ||||
| 57 | + | var r0 []byte | |||
| 58 | + | var r1 error | |||
| 59 | + | if returnFunc, ok := ret.Get(0).(func(context.Context) ([]byte, error)); ok { | |||
| 60 | + | return returnFunc(ctx) | |||
| 61 | + | } | |||
| 62 | + | if returnFunc, ok := ret.Get(0).(func(context.Context) []byte); ok { | |||
| 63 | + | r0 = returnFunc(ctx) | |||
| 64 | + | } else { | |||
| 65 | + | if ret.Get(0) != nil { | |||
| 66 | + | r0 = ret.Get(0).([]byte) | |||
| 67 | + | } | |||
| 68 | + | } | |||
| 69 | + | if returnFunc, ok := ret.Get(1).(func(context.Context) error); ok { | |||
| 70 | + | r1 = returnFunc(ctx) | |||
| 71 | + | } else { | |||
| 72 | + | r1 = ret.Error(1) | |||
| 73 | + | } | |||
| 74 | + | return r0, r1 | |||
| 75 | + | } | |||
| 76 | + | ||||
| 77 | + | // IssueKeyStore_Key_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Key' | |||
| 78 | + | type IssueKeyStore_Key_Call struct { | |||
| 79 | + | *mock.Call | |||
| 80 | + | } | |||
| 81 | + | ||||
| 82 | + | // Key is a helper method to define mock.On call | |||
| 83 | + | // - ctx context.Context | |||
| 84 | + | func (_e *IssueKeyStore_Expecter) Key(ctx any) *IssueKeyStore_Key_Call { | |||
| 85 | + | return &IssueKeyStore_Key_Call{Call: _e.mock.On("Key", ctx)} | |||
| 86 | + | } | |||
| 87 | + | ||||
| 88 | + | func (_c *IssueKeyStore_Key_Call) Run(run func(ctx context.Context)) *IssueKeyStore_Key_Call { | |||
| 89 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 90 | + | var arg0 context.Context | |||
| 91 | + | if args[0] != nil { | |||
| 92 | + | arg0 = args[0].(context.Context) | |||
| 93 | + | } | |||
| 94 | + | run( | |||
| 95 | + | arg0, | |||
| 96 | + | ) | |||
| 97 | + | }) | |||
| 98 | + | return _c | |||
| 99 | + | } | |||
| 100 | + | ||||
| 101 | + | func (_c *IssueKeyStore_Key_Call) Return(bytes []byte, err error) *IssueKeyStore_Key_Call { | |||
| 102 | + | _c.Call.Return(bytes, err) | |||
| 103 | + | return _c | |||
| 104 | + | } | |||
| 105 | + | ||||
| 106 | + | func (_c *IssueKeyStore_Key_Call) RunAndReturn(run func(ctx context.Context) ([]byte, error)) *IssueKeyStore_Key_Call { | |||
| 107 | + | _c.Call.Return(run) | |||
| 108 | + | return _c | |||
| 109 | + | } | |||
A internal/ports/mocks/IssueModerationService.go +280 -0
| @@ -0,0 +1,280 @@ | |||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |
| 2 | + | // github.com/vektra/mockery | |
| 3 | + | // template: testify | |
| 4 | + | ||
| 5 | + | package mocks | |
| 6 | + | ||
| 7 | + | import ( | |
| 8 | + | "context" | |
| 9 | + | ||
| 10 | + | "bnema.dev/ermite/internal/domain" | |
| 11 | + | "bnema.dev/ermite/internal/ports" | |
| 12 | + | mock "github.com/stretchr/testify/mock" | |
| 13 | + | ) | |
| 14 | + | ||
| 15 | + | // NewIssueModerationService creates a new instance of IssueModerationService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |
| 16 | + | // The first argument is typically a *testing.T value. | |
| 17 | + | func NewIssueModerationService(t interface { | |
| 18 | + | mock.TestingT | |
| 19 | + | Cleanup(func()) | |
| 20 | + | }) *IssueModerationService { | |
| 21 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 22 | + | helper.Helper() | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | mock := &IssueModerationService{} | |
| 26 | + | mock.Mock.Test(t) | |
| 27 | + | ||
| 28 | + | t.Cleanup(func() { | |
| 29 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 30 | + | helper.Helper() | |
| 31 | + | } | |
| 32 | + | mock.AssertExpectations(t) | |
| 33 | + | }) | |
| 34 | + | ||
| 35 | + | return mock | |
| 36 | + | } | |
| 37 | + | ||
| 38 | + | // IssueModerationService is an autogenerated mock type for the IssueModerationService type | |
| 39 | + | type IssueModerationService struct { | |
| 40 | + | mock.Mock | |
| 41 | + | } | |
| 42 | + | ||
| 43 | + | type IssueModerationService_Expecter struct { | |
| 44 | + | mock *mock.Mock | |
| 45 | + | } | |
| 46 | + | ||
| 47 | + | func (_m *IssueModerationService) EXPECT() *IssueModerationService_Expecter { | |
| 48 | + | return &IssueModerationService_Expecter{mock: &_m.Mock} | |
| 49 | + | } | |
| 50 | + | ||
| 51 | + | // Approve provides a mock function for the type IssueModerationService | |
| 52 | + | func (_mock *IssueModerationService) Approve(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error) { | |
| 53 | + | ret := _mock.Called(ctx, p, repo, id) | |
| 54 | + | ||
| 55 | + | if len(ret) == 0 { | |
| 56 | + | panic("no return value specified for Approve") | |
| 57 | + | } | |
| 58 | + | ||
| 59 | + | var r0 domain.Issue | |
| 60 | + | var r1 error | |
| 61 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.Principal, domain.RepoName, domain.PendingIssueID) (domain.Issue, error)); ok { | |
| 62 | + | return returnFunc(ctx, p, repo, id) | |
| 63 | + | } | |
| 64 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.Principal, domain.RepoName, domain.PendingIssueID) domain.Issue); ok { | |
| 65 | + | r0 = returnFunc(ctx, p, repo, id) | |
| 66 | + | } else { | |
| 67 | + | r0 = ret.Get(0).(domain.Issue) | |
| 68 | + | } | |
| 69 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, domain.Principal, domain.RepoName, domain.PendingIssueID) error); ok { | |
| 70 | + | r1 = returnFunc(ctx, p, repo, id) | |
| 71 | + | } else { | |
| 72 | + | r1 = ret.Error(1) | |
| 73 | + | } | |
| 74 | + | return r0, r1 | |
| 75 | + | } | |
| 76 | + | ||
| 77 | + | // IssueModerationService_Approve_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Approve' | |
| 78 | + | type IssueModerationService_Approve_Call struct { | |
| 79 | + | *mock.Call | |
| 80 | + | } | |
| 81 | + | ||
| 82 | + | // Approve is a helper method to define mock.On call | |
| 83 | + | // - ctx context.Context | |
| 84 | + | // - p domain.Principal | |
| 85 | + | // - repo domain.RepoName | |
| 86 | + | // - id domain.PendingIssueID | |
| 87 | + | func (_e *IssueModerationService_Expecter) Approve(ctx any, p any, repo any, id any) *IssueModerationService_Approve_Call { | |
| 88 | + | return &IssueModerationService_Approve_Call{Call: _e.mock.On("Approve", ctx, p, repo, id)} | |
| 89 | + | } | |
| 90 | + | ||
| 91 | + | func (_c *IssueModerationService_Approve_Call) Run(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID)) *IssueModerationService_Approve_Call { | |
| 92 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 93 | + | var arg0 context.Context | |
| 94 | + | if args[0] != nil { | |
| 95 | + | arg0 = args[0].(context.Context) | |
| 96 | + | } | |
| 97 | + | var arg1 domain.Principal | |
| 98 | + | if args[1] != nil { | |
| 99 | + | arg1 = args[1].(domain.Principal) | |
| 100 | + | } | |
| 101 | + | var arg2 domain.RepoName | |
| 102 | + | if args[2] != nil { | |
| 103 | + | arg2 = args[2].(domain.RepoName) | |
| 104 | + | } | |
| 105 | + | var arg3 domain.PendingIssueID | |
| 106 | + | if args[3] != nil { | |
| 107 | + | arg3 = args[3].(domain.PendingIssueID) | |
| 108 | + | } | |
| 109 | + | run( | |
| 110 | + | arg0, | |
| 111 | + | arg1, | |
| 112 | + | arg2, | |
| 113 | + | arg3, | |
| 114 | + | ) | |
| 115 | + | }) | |
| 116 | + | return _c | |
| 117 | + | } | |
| 118 | + | ||
| 119 | + | func (_c *IssueModerationService_Approve_Call) Return(issue domain.Issue, err error) *IssueModerationService_Approve_Call { | |
| 120 | + | _c.Call.Return(issue, err) | |
| 121 | + | return _c | |
| 122 | + | } | |
| 123 | + | ||
| 124 | + | func (_c *IssueModerationService_Approve_Call) RunAndReturn(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error)) *IssueModerationService_Approve_Call { | |
| 125 | + | _c.Call.Return(run) | |
| 126 | + | return _c | |
| 127 | + | } | |
| 128 | + | ||
| 129 | + | // ListPending provides a mock function for the type IssueModerationService | |
| 130 | + | func (_mock *IssueModerationService) ListPending(ctx context.Context, p domain.Principal, repo domain.RepoName, page ports.ListPendingParams) (ports.PendingIssuePage, error) { | |
| 131 | + | ret := _mock.Called(ctx, p, repo, page) | |
| 132 | + | ||
| 133 | + | if len(ret) == 0 { | |
| 134 | + | panic("no return value specified for ListPending") | |
| 135 | + | } | |
| 136 | + | ||
| 137 | + | var r0 ports.PendingIssuePage | |
| 138 | + | var r1 error | |
| 139 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.Principal, domain.RepoName, ports.ListPendingParams) (ports.PendingIssuePage, error)); ok { | |
| 140 | + | return returnFunc(ctx, p, repo, page) | |
| 141 | + | } | |
| 142 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.Principal, domain.RepoName, ports.ListPendingParams) ports.PendingIssuePage); ok { | |
| 143 | + | r0 = returnFunc(ctx, p, repo, page) | |
| 144 | + | } else { | |
| 145 | + | r0 = ret.Get(0).(ports.PendingIssuePage) | |
| 146 | + | } | |
| 147 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, domain.Principal, domain.RepoName, ports.ListPendingParams) error); ok { | |
| 148 | + | r1 = returnFunc(ctx, p, repo, page) | |
| 149 | + | } else { | |
| 150 | + | r1 = ret.Error(1) | |
| 151 | + | } | |
| 152 | + | return r0, r1 | |
| 153 | + | } | |
| 154 | + | ||
| 155 | + | // IssueModerationService_ListPending_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListPending' | |
| 156 | + | type IssueModerationService_ListPending_Call struct { | |
| 157 | + | *mock.Call | |
| 158 | + | } | |
| 159 | + | ||
| 160 | + | // ListPending is a helper method to define mock.On call | |
| 161 | + | // - ctx context.Context | |
| 162 | + | // - p domain.Principal | |
| 163 | + | // - repo domain.RepoName | |
| 164 | + | // - page ports.ListPendingParams | |
| 165 | + | func (_e *IssueModerationService_Expecter) ListPending(ctx any, p any, repo any, page any) *IssueModerationService_ListPending_Call { | |
| 166 | + | return &IssueModerationService_ListPending_Call{Call: _e.mock.On("ListPending", ctx, p, repo, page)} | |
| 167 | + | } | |
| 168 | + | ||
| 169 | + | func (_c *IssueModerationService_ListPending_Call) Run(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, page ports.ListPendingParams)) *IssueModerationService_ListPending_Call { | |
| 170 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 171 | + | var arg0 context.Context | |
| 172 | + | if args[0] != nil { | |
| 173 | + | arg0 = args[0].(context.Context) | |
| 174 | + | } | |
| 175 | + | var arg1 domain.Principal | |
| 176 | + | if args[1] != nil { | |
| 177 | + | arg1 = args[1].(domain.Principal) | |
| 178 | + | } | |
| 179 | + | var arg2 domain.RepoName | |
| 180 | + | if args[2] != nil { | |
| 181 | + | arg2 = args[2].(domain.RepoName) | |
| 182 | + | } | |
| 183 | + | var arg3 ports.ListPendingParams | |
| 184 | + | if args[3] != nil { | |
| 185 | + | arg3 = args[3].(ports.ListPendingParams) | |
| 186 | + | } | |
| 187 | + | run( | |
| 188 | + | arg0, | |
| 189 | + | arg1, | |
| 190 | + | arg2, | |
| 191 | + | arg3, | |
| 192 | + | ) | |
| 193 | + | }) | |
| 194 | + | return _c | |
| 195 | + | } | |
| 196 | + | ||
| 197 | + | func (_c *IssueModerationService_ListPending_Call) Return(pendingIssuePage ports.PendingIssuePage, err error) *IssueModerationService_ListPending_Call { | |
| 198 | + | _c.Call.Return(pendingIssuePage, err) | |
| 199 | + | return _c | |
| 200 | + | } | |
| 201 | + | ||
| 202 | + | func (_c *IssueModerationService_ListPending_Call) RunAndReturn(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, page ports.ListPendingParams) (ports.PendingIssuePage, error)) *IssueModerationService_ListPending_Call { | |
| 203 | + | _c.Call.Return(run) | |
| 204 | + | return _c | |
| 205 | + | } | |
| 206 | + | ||
| 207 | + | // Reject provides a mock function for the type IssueModerationService | |
| 208 | + | func (_mock *IssueModerationService) Reject(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID, ban bool) error { | |
| 209 | + | ret := _mock.Called(ctx, p, repo, id, ban) | |
| 210 | + | ||
| 211 | + | if len(ret) == 0 { | |
| 212 | + | panic("no return value specified for Reject") | |
| 213 | + | } | |
| 214 | + | ||
| 215 | + | var r0 error | |
| 216 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.Principal, domain.RepoName, domain.PendingIssueID, bool) error); ok { | |
| 217 | + | r0 = returnFunc(ctx, p, repo, id, ban) | |
| 218 | + | } else { | |
| 219 | + | r0 = ret.Error(0) | |
| 220 | + | } | |
| 221 | + | return r0 | |
| 222 | + | } | |
| 223 | + | ||
| 224 | + | // IssueModerationService_Reject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Reject' | |
| 225 | + | type IssueModerationService_Reject_Call struct { | |
| 226 | + | *mock.Call | |
| 227 | + | } | |
| 228 | + | ||
| 229 | + | // Reject is a helper method to define mock.On call | |
| 230 | + | // - ctx context.Context | |
| 231 | + | // - p domain.Principal | |
| 232 | + | // - repo domain.RepoName | |
| 233 | + | // - id domain.PendingIssueID | |
| 234 | + | // - ban bool | |
| 235 | + | func (_e *IssueModerationService_Expecter) Reject(ctx any, p any, repo any, id any, ban any) *IssueModerationService_Reject_Call { | |
| 236 | + | return &IssueModerationService_Reject_Call{Call: _e.mock.On("Reject", ctx, p, repo, id, ban)} | |
| 237 | + | } | |
| 238 | + | ||
| 239 | + | func (_c *IssueModerationService_Reject_Call) Run(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID, ban bool)) *IssueModerationService_Reject_Call { | |
| 240 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 241 | + | var arg0 context.Context | |
| 242 | + | if args[0] != nil { | |
| 243 | + | arg0 = args[0].(context.Context) | |
| 244 | + | } | |
| 245 | + | var arg1 domain.Principal | |
| 246 | + | if args[1] != nil { | |
| 247 | + | arg1 = args[1].(domain.Principal) | |
| 248 | + | } | |
| 249 | + | var arg2 domain.RepoName | |
| 250 | + | if args[2] != nil { | |
| 251 | + | arg2 = args[2].(domain.RepoName) | |
| 252 | + | } | |
| 253 | + | var arg3 domain.PendingIssueID | |
| 254 | + | if args[3] != nil { | |
| 255 | + | arg3 = args[3].(domain.PendingIssueID) | |
| 256 | + | } | |
| 257 | + | var arg4 bool | |
| 258 | + | if args[4] != nil { | |
| 259 | + | arg4 = args[4].(bool) | |
| 260 | + | } | |
| 261 | + | run( | |
| 262 | + | arg0, | |
| 263 | + | arg1, | |
| 264 | + | arg2, | |
| 265 | + | arg3, | |
| 266 | + | arg4, | |
| 267 | + | ) | |
| 268 | + | }) | |
| 269 | + | return _c | |
| 270 | + | } | |
| 271 | + | ||
| 272 | + | func (_c *IssueModerationService_Reject_Call) Return(err error) *IssueModerationService_Reject_Call { | |
| 273 | + | _c.Call.Return(err) | |
| 274 | + | return _c | |
| 275 | + | } | |
| 276 | + | ||
| 277 | + | func (_c *IssueModerationService_Reject_Call) RunAndReturn(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID, ban bool) error) *IssueModerationService_Reject_Call { | |
| 278 | + | _c.Call.Return(run) | |
| 279 | + | return _c | |
| 280 | + | } | |
| @@ -0,0 +1,280 @@ | |||||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |||
| 2 | + | // github.com/vektra/mockery | |||
| 3 | + | // template: testify | |||
| 4 | + | ||||
| 5 | + | package mocks | |||
| 6 | + | ||||
| 7 | + | import ( | |||
| 8 | + | "context" | |||
| 9 | + | ||||
| 10 | + | "bnema.dev/ermite/internal/domain" | |||
| 11 | + | "bnema.dev/ermite/internal/ports" | |||
| 12 | + | mock "github.com/stretchr/testify/mock" | |||
| 13 | + | ) | |||
| 14 | + | ||||
| 15 | + | // NewIssueModerationService creates a new instance of IssueModerationService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |||
| 16 | + | // The first argument is typically a *testing.T value. | |||
| 17 | + | func NewIssueModerationService(t interface { | |||
| 18 | + | mock.TestingT | |||
| 19 | + | Cleanup(func()) | |||
| 20 | + | }) *IssueModerationService { | |||
| 21 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 22 | + | helper.Helper() | |||
| 23 | + | } | |||
| 24 | + | ||||
| 25 | + | mock := &IssueModerationService{} | |||
| 26 | + | mock.Mock.Test(t) | |||
| 27 | + | ||||
| 28 | + | t.Cleanup(func() { | |||
| 29 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 30 | + | helper.Helper() | |||
| 31 | + | } | |||
| 32 | + | mock.AssertExpectations(t) | |||
| 33 | + | }) | |||
| 34 | + | ||||
| 35 | + | return mock | |||
| 36 | + | } | |||
| 37 | + | ||||
| 38 | + | // IssueModerationService is an autogenerated mock type for the IssueModerationService type | |||
| 39 | + | type IssueModerationService struct { | |||
| 40 | + | mock.Mock | |||
| 41 | + | } | |||
| 42 | + | ||||
| 43 | + | type IssueModerationService_Expecter struct { | |||
| 44 | + | mock *mock.Mock | |||
| 45 | + | } | |||
| 46 | + | ||||
| 47 | + | func (_m *IssueModerationService) EXPECT() *IssueModerationService_Expecter { | |||
| 48 | + | return &IssueModerationService_Expecter{mock: &_m.Mock} | |||
| 49 | + | } | |||
| 50 | + | ||||
| 51 | + | // Approve provides a mock function for the type IssueModerationService | |||
| 52 | + | func (_mock *IssueModerationService) Approve(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error) { | |||
| 53 | + | ret := _mock.Called(ctx, p, repo, id) | |||
| 54 | + | ||||
| 55 | + | if len(ret) == 0 { | |||
| 56 | + | panic("no return value specified for Approve") | |||
| 57 | + | } | |||
| 58 | + | ||||
| 59 | + | var r0 domain.Issue | |||
| 60 | + | var r1 error | |||
| 61 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.Principal, domain.RepoName, domain.PendingIssueID) (domain.Issue, error)); ok { | |||
| 62 | + | return returnFunc(ctx, p, repo, id) | |||
| 63 | + | } | |||
| 64 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.Principal, domain.RepoName, domain.PendingIssueID) domain.Issue); ok { | |||
| 65 | + | r0 = returnFunc(ctx, p, repo, id) | |||
| 66 | + | } else { | |||
| 67 | + | r0 = ret.Get(0).(domain.Issue) | |||
| 68 | + | } | |||
| 69 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, domain.Principal, domain.RepoName, domain.PendingIssueID) error); ok { | |||
| 70 | + | r1 = returnFunc(ctx, p, repo, id) | |||
| 71 | + | } else { | |||
| 72 | + | r1 = ret.Error(1) | |||
| 73 | + | } | |||
| 74 | + | return r0, r1 | |||
| 75 | + | } | |||
| 76 | + | ||||
| 77 | + | // IssueModerationService_Approve_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Approve' | |||
| 78 | + | type IssueModerationService_Approve_Call struct { | |||
| 79 | + | *mock.Call | |||
| 80 | + | } | |||
| 81 | + | ||||
| 82 | + | // Approve is a helper method to define mock.On call | |||
| 83 | + | // - ctx context.Context | |||
| 84 | + | // - p domain.Principal | |||
| 85 | + | // - repo domain.RepoName | |||
| 86 | + | // - id domain.PendingIssueID | |||
| 87 | + | func (_e *IssueModerationService_Expecter) Approve(ctx any, p any, repo any, id any) *IssueModerationService_Approve_Call { | |||
| 88 | + | return &IssueModerationService_Approve_Call{Call: _e.mock.On("Approve", ctx, p, repo, id)} | |||
| 89 | + | } | |||
| 90 | + | ||||
| 91 | + | func (_c *IssueModerationService_Approve_Call) Run(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID)) *IssueModerationService_Approve_Call { | |||
| 92 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 93 | + | var arg0 context.Context | |||
| 94 | + | if args[0] != nil { | |||
| 95 | + | arg0 = args[0].(context.Context) | |||
| 96 | + | } | |||
| 97 | + | var arg1 domain.Principal | |||
| 98 | + | if args[1] != nil { | |||
| 99 | + | arg1 = args[1].(domain.Principal) | |||
| 100 | + | } | |||
| 101 | + | var arg2 domain.RepoName | |||
| 102 | + | if args[2] != nil { | |||
| 103 | + | arg2 = args[2].(domain.RepoName) | |||
| 104 | + | } | |||
| 105 | + | var arg3 domain.PendingIssueID | |||
| 106 | + | if args[3] != nil { | |||
| 107 | + | arg3 = args[3].(domain.PendingIssueID) | |||
| 108 | + | } | |||
| 109 | + | run( | |||
| 110 | + | arg0, | |||
| 111 | + | arg1, | |||
| 112 | + | arg2, | |||
| 113 | + | arg3, | |||
| 114 | + | ) | |||
| 115 | + | }) | |||
| 116 | + | return _c | |||
| 117 | + | } | |||
| 118 | + | ||||
| 119 | + | func (_c *IssueModerationService_Approve_Call) Return(issue domain.Issue, err error) *IssueModerationService_Approve_Call { | |||
| 120 | + | _c.Call.Return(issue, err) | |||
| 121 | + | return _c | |||
| 122 | + | } | |||
| 123 | + | ||||
| 124 | + | func (_c *IssueModerationService_Approve_Call) RunAndReturn(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error)) *IssueModerationService_Approve_Call { | |||
| 125 | + | _c.Call.Return(run) | |||
| 126 | + | return _c | |||
| 127 | + | } | |||
| 128 | + | ||||
| 129 | + | // ListPending provides a mock function for the type IssueModerationService | |||
| 130 | + | func (_mock *IssueModerationService) ListPending(ctx context.Context, p domain.Principal, repo domain.RepoName, page ports.ListPendingParams) (ports.PendingIssuePage, error) { | |||
| 131 | + | ret := _mock.Called(ctx, p, repo, page) | |||
| 132 | + | ||||
| 133 | + | if len(ret) == 0 { | |||
| 134 | + | panic("no return value specified for ListPending") | |||
| 135 | + | } | |||
| 136 | + | ||||
| 137 | + | var r0 ports.PendingIssuePage | |||
| 138 | + | var r1 error | |||
| 139 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.Principal, domain.RepoName, ports.ListPendingParams) (ports.PendingIssuePage, error)); ok { | |||
| 140 | + | return returnFunc(ctx, p, repo, page) | |||
| 141 | + | } | |||
| 142 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.Principal, domain.RepoName, ports.ListPendingParams) ports.PendingIssuePage); ok { | |||
| 143 | + | r0 = returnFunc(ctx, p, repo, page) | |||
| 144 | + | } else { | |||
| 145 | + | r0 = ret.Get(0).(ports.PendingIssuePage) | |||
| 146 | + | } | |||
| 147 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, domain.Principal, domain.RepoName, ports.ListPendingParams) error); ok { | |||
| 148 | + | r1 = returnFunc(ctx, p, repo, page) | |||
| 149 | + | } else { | |||
| 150 | + | r1 = ret.Error(1) | |||
| 151 | + | } | |||
| 152 | + | return r0, r1 | |||
| 153 | + | } | |||
| 154 | + | ||||
| 155 | + | // IssueModerationService_ListPending_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListPending' | |||
| 156 | + | type IssueModerationService_ListPending_Call struct { | |||
| 157 | + | *mock.Call | |||
| 158 | + | } | |||
| 159 | + | ||||
| 160 | + | // ListPending is a helper method to define mock.On call | |||
| 161 | + | // - ctx context.Context | |||
| 162 | + | // - p domain.Principal | |||
| 163 | + | // - repo domain.RepoName | |||
| 164 | + | // - page ports.ListPendingParams | |||
| 165 | + | func (_e *IssueModerationService_Expecter) ListPending(ctx any, p any, repo any, page any) *IssueModerationService_ListPending_Call { | |||
| 166 | + | return &IssueModerationService_ListPending_Call{Call: _e.mock.On("ListPending", ctx, p, repo, page)} | |||
| 167 | + | } | |||
| 168 | + | ||||
| 169 | + | func (_c *IssueModerationService_ListPending_Call) Run(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, page ports.ListPendingParams)) *IssueModerationService_ListPending_Call { | |||
| 170 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 171 | + | var arg0 context.Context | |||
| 172 | + | if args[0] != nil { | |||
| 173 | + | arg0 = args[0].(context.Context) | |||
| 174 | + | } | |||
| 175 | + | var arg1 domain.Principal | |||
| 176 | + | if args[1] != nil { | |||
| 177 | + | arg1 = args[1].(domain.Principal) | |||
| 178 | + | } | |||
| 179 | + | var arg2 domain.RepoName | |||
| 180 | + | if args[2] != nil { | |||
| 181 | + | arg2 = args[2].(domain.RepoName) | |||
| 182 | + | } | |||
| 183 | + | var arg3 ports.ListPendingParams | |||
| 184 | + | if args[3] != nil { | |||
| 185 | + | arg3 = args[3].(ports.ListPendingParams) | |||
| 186 | + | } | |||
| 187 | + | run( | |||
| 188 | + | arg0, | |||
| 189 | + | arg1, | |||
| 190 | + | arg2, | |||
| 191 | + | arg3, | |||
| 192 | + | ) | |||
| 193 | + | }) | |||
| 194 | + | return _c | |||
| 195 | + | } | |||
| 196 | + | ||||
| 197 | + | func (_c *IssueModerationService_ListPending_Call) Return(pendingIssuePage ports.PendingIssuePage, err error) *IssueModerationService_ListPending_Call { | |||
| 198 | + | _c.Call.Return(pendingIssuePage, err) | |||
| 199 | + | return _c | |||
| 200 | + | } | |||
| 201 | + | ||||
| 202 | + | func (_c *IssueModerationService_ListPending_Call) RunAndReturn(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, page ports.ListPendingParams) (ports.PendingIssuePage, error)) *IssueModerationService_ListPending_Call { | |||
| 203 | + | _c.Call.Return(run) | |||
| 204 | + | return _c | |||
| 205 | + | } | |||
| 206 | + | ||||
| 207 | + | // Reject provides a mock function for the type IssueModerationService | |||
| 208 | + | func (_mock *IssueModerationService) Reject(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID, ban bool) error { | |||
| 209 | + | ret := _mock.Called(ctx, p, repo, id, ban) | |||
| 210 | + | ||||
| 211 | + | if len(ret) == 0 { | |||
| 212 | + | panic("no return value specified for Reject") | |||
| 213 | + | } | |||
| 214 | + | ||||
| 215 | + | var r0 error | |||
| 216 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.Principal, domain.RepoName, domain.PendingIssueID, bool) error); ok { | |||
| 217 | + | r0 = returnFunc(ctx, p, repo, id, ban) | |||
| 218 | + | } else { | |||
| 219 | + | r0 = ret.Error(0) | |||
| 220 | + | } | |||
| 221 | + | return r0 | |||
| 222 | + | } | |||
| 223 | + | ||||
| 224 | + | // IssueModerationService_Reject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Reject' | |||
| 225 | + | type IssueModerationService_Reject_Call struct { | |||
| 226 | + | *mock.Call | |||
| 227 | + | } | |||
| 228 | + | ||||
| 229 | + | // Reject is a helper method to define mock.On call | |||
| 230 | + | // - ctx context.Context | |||
| 231 | + | // - p domain.Principal | |||
| 232 | + | // - repo domain.RepoName | |||
| 233 | + | // - id domain.PendingIssueID | |||
| 234 | + | // - ban bool | |||
| 235 | + | func (_e *IssueModerationService_Expecter) Reject(ctx any, p any, repo any, id any, ban any) *IssueModerationService_Reject_Call { | |||
| 236 | + | return &IssueModerationService_Reject_Call{Call: _e.mock.On("Reject", ctx, p, repo, id, ban)} | |||
| 237 | + | } | |||
| 238 | + | ||||
| 239 | + | func (_c *IssueModerationService_Reject_Call) Run(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID, ban bool)) *IssueModerationService_Reject_Call { | |||
| 240 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 241 | + | var arg0 context.Context | |||
| 242 | + | if args[0] != nil { | |||
| 243 | + | arg0 = args[0].(context.Context) | |||
| 244 | + | } | |||
| 245 | + | var arg1 domain.Principal | |||
| 246 | + | if args[1] != nil { | |||
| 247 | + | arg1 = args[1].(domain.Principal) | |||
| 248 | + | } | |||
| 249 | + | var arg2 domain.RepoName | |||
| 250 | + | if args[2] != nil { | |||
| 251 | + | arg2 = args[2].(domain.RepoName) | |||
| 252 | + | } | |||
| 253 | + | var arg3 domain.PendingIssueID | |||
| 254 | + | if args[3] != nil { | |||
| 255 | + | arg3 = args[3].(domain.PendingIssueID) | |||
| 256 | + | } | |||
| 257 | + | var arg4 bool | |||
| 258 | + | if args[4] != nil { | |||
| 259 | + | arg4 = args[4].(bool) | |||
| 260 | + | } | |||
| 261 | + | run( | |||
| 262 | + | arg0, | |||
| 263 | + | arg1, | |||
| 264 | + | arg2, | |||
| 265 | + | arg3, | |||
| 266 | + | arg4, | |||
| 267 | + | ) | |||
| 268 | + | }) | |||
| 269 | + | return _c | |||
| 270 | + | } | |||
| 271 | + | ||||
| 272 | + | func (_c *IssueModerationService_Reject_Call) Return(err error) *IssueModerationService_Reject_Call { | |||
| 273 | + | _c.Call.Return(err) | |||
| 274 | + | return _c | |||
| 275 | + | } | |||
| 276 | + | ||||
| 277 | + | func (_c *IssueModerationService_Reject_Call) RunAndReturn(run func(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID, ban bool) error) *IssueModerationService_Reject_Call { | |||
| 278 | + | _c.Call.Return(run) | |||
| 279 | + | return _c | |||
| 280 | + | } | |||
A internal/ports/mocks/PendingIssueStore.go +445 -0
| @@ -0,0 +1,445 @@ | |||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |
| 2 | + | // github.com/vektra/mockery | |
| 3 | + | // template: testify | |
| 4 | + | ||
| 5 | + | package mocks | |
| 6 | + | ||
| 7 | + | import ( | |
| 8 | + | "context" | |
| 9 | + | ||
| 10 | + | "bnema.dev/ermite/internal/domain" | |
| 11 | + | "bnema.dev/ermite/internal/ports" | |
| 12 | + | mock "github.com/stretchr/testify/mock" | |
| 13 | + | ) | |
| 14 | + | ||
| 15 | + | // NewPendingIssueStore creates a new instance of PendingIssueStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |
| 16 | + | // The first argument is typically a *testing.T value. | |
| 17 | + | func NewPendingIssueStore(t interface { | |
| 18 | + | mock.TestingT | |
| 19 | + | Cleanup(func()) | |
| 20 | + | }) *PendingIssueStore { | |
| 21 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 22 | + | helper.Helper() | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | mock := &PendingIssueStore{} | |
| 26 | + | mock.Mock.Test(t) | |
| 27 | + | ||
| 28 | + | t.Cleanup(func() { | |
| 29 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 30 | + | helper.Helper() | |
| 31 | + | } | |
| 32 | + | mock.AssertExpectations(t) | |
| 33 | + | }) | |
| 34 | + | ||
| 35 | + | return mock | |
| 36 | + | } | |
| 37 | + | ||
| 38 | + | // PendingIssueStore is an autogenerated mock type for the PendingIssueStore type | |
| 39 | + | type PendingIssueStore struct { | |
| 40 | + | mock.Mock | |
| 41 | + | } | |
| 42 | + | ||
| 43 | + | type PendingIssueStore_Expecter struct { | |
| 44 | + | mock *mock.Mock | |
| 45 | + | } | |
| 46 | + | ||
| 47 | + | func (_m *PendingIssueStore) EXPECT() *PendingIssueStore_Expecter { | |
| 48 | + | return &PendingIssueStore_Expecter{mock: &_m.Mock} | |
| 49 | + | } | |
| 50 | + | ||
| 51 | + | // Approve provides a mock function for the type PendingIssueStore | |
| 52 | + | func (_mock *PendingIssueStore) Approve(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error) { | |
| 53 | + | ret := _mock.Called(ctx, repo, id) | |
| 54 | + | ||
| 55 | + | if len(ret) == 0 { | |
| 56 | + | panic("no return value specified for Approve") | |
| 57 | + | } | |
| 58 | + | ||
| 59 | + | var r0 domain.Issue | |
| 60 | + | var r1 error | |
| 61 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, domain.PendingIssueID) (domain.Issue, error)); ok { | |
| 62 | + | return returnFunc(ctx, repo, id) | |
| 63 | + | } | |
| 64 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, domain.PendingIssueID) domain.Issue); ok { | |
| 65 | + | r0 = returnFunc(ctx, repo, id) | |
| 66 | + | } else { | |
| 67 | + | r0 = ret.Get(0).(domain.Issue) | |
| 68 | + | } | |
| 69 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, domain.RepoName, domain.PendingIssueID) error); ok { | |
| 70 | + | r1 = returnFunc(ctx, repo, id) | |
| 71 | + | } else { | |
| 72 | + | r1 = ret.Error(1) | |
| 73 | + | } | |
| 74 | + | return r0, r1 | |
| 75 | + | } | |
| 76 | + | ||
| 77 | + | // PendingIssueStore_Approve_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Approve' | |
| 78 | + | type PendingIssueStore_Approve_Call struct { | |
| 79 | + | *mock.Call | |
| 80 | + | } | |
| 81 | + | ||
| 82 | + | // Approve is a helper method to define mock.On call | |
| 83 | + | // - ctx context.Context | |
| 84 | + | // - repo domain.RepoName | |
| 85 | + | // - id domain.PendingIssueID | |
| 86 | + | func (_e *PendingIssueStore_Expecter) Approve(ctx any, repo any, id any) *PendingIssueStore_Approve_Call { | |
| 87 | + | return &PendingIssueStore_Approve_Call{Call: _e.mock.On("Approve", ctx, repo, id)} | |
| 88 | + | } | |
| 89 | + | ||
| 90 | + | func (_c *PendingIssueStore_Approve_Call) Run(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID)) *PendingIssueStore_Approve_Call { | |
| 91 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 92 | + | var arg0 context.Context | |
| 93 | + | if args[0] != nil { | |
| 94 | + | arg0 = args[0].(context.Context) | |
| 95 | + | } | |
| 96 | + | var arg1 domain.RepoName | |
| 97 | + | if args[1] != nil { | |
| 98 | + | arg1 = args[1].(domain.RepoName) | |
| 99 | + | } | |
| 100 | + | var arg2 domain.PendingIssueID | |
| 101 | + | if args[2] != nil { | |
| 102 | + | arg2 = args[2].(domain.PendingIssueID) | |
| 103 | + | } | |
| 104 | + | run( | |
| 105 | + | arg0, | |
| 106 | + | arg1, | |
| 107 | + | arg2, | |
| 108 | + | ) | |
| 109 | + | }) | |
| 110 | + | return _c | |
| 111 | + | } | |
| 112 | + | ||
| 113 | + | func (_c *PendingIssueStore_Approve_Call) Return(issue domain.Issue, err error) *PendingIssueStore_Approve_Call { | |
| 114 | + | _c.Call.Return(issue, err) | |
| 115 | + | return _c | |
| 116 | + | } | |
| 117 | + | ||
| 118 | + | func (_c *PendingIssueStore_Approve_Call) RunAndReturn(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error)) *PendingIssueStore_Approve_Call { | |
| 119 | + | _c.Call.Return(run) | |
| 120 | + | return _c | |
| 121 | + | } | |
| 122 | + | ||
| 123 | + | // Count provides a mock function for the type PendingIssueStore | |
| 124 | + | func (_mock *PendingIssueStore) Count(ctx context.Context) (int, error) { | |
| 125 | + | ret := _mock.Called(ctx) | |
| 126 | + | ||
| 127 | + | if len(ret) == 0 { | |
| 128 | + | panic("no return value specified for Count") | |
| 129 | + | } | |
| 130 | + | ||
| 131 | + | var r0 int | |
| 132 | + | var r1 error | |
| 133 | + | if returnFunc, ok := ret.Get(0).(func(context.Context) (int, error)); ok { | |
| 134 | + | return returnFunc(ctx) | |
| 135 | + | } | |
| 136 | + | if returnFunc, ok := ret.Get(0).(func(context.Context) int); ok { | |
| 137 | + | r0 = returnFunc(ctx) | |
| 138 | + | } else { | |
| 139 | + | r0 = ret.Get(0).(int) | |
| 140 | + | } | |
| 141 | + | if returnFunc, ok := ret.Get(1).(func(context.Context) error); ok { | |
| 142 | + | r1 = returnFunc(ctx) | |
| 143 | + | } else { | |
| 144 | + | r1 = ret.Error(1) | |
| 145 | + | } | |
| 146 | + | return r0, r1 | |
| 147 | + | } | |
| 148 | + | ||
| 149 | + | // PendingIssueStore_Count_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Count' | |
| 150 | + | type PendingIssueStore_Count_Call struct { | |
| 151 | + | *mock.Call | |
| 152 | + | } | |
| 153 | + | ||
| 154 | + | // Count is a helper method to define mock.On call | |
| 155 | + | // - ctx context.Context | |
| 156 | + | func (_e *PendingIssueStore_Expecter) Count(ctx any) *PendingIssueStore_Count_Call { | |
| 157 | + | return &PendingIssueStore_Count_Call{Call: _e.mock.On("Count", ctx)} | |
| 158 | + | } | |
| 159 | + | ||
| 160 | + | func (_c *PendingIssueStore_Count_Call) Run(run func(ctx context.Context)) *PendingIssueStore_Count_Call { | |
| 161 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 162 | + | var arg0 context.Context | |
| 163 | + | if args[0] != nil { | |
| 164 | + | arg0 = args[0].(context.Context) | |
| 165 | + | } | |
| 166 | + | run( | |
| 167 | + | arg0, | |
| 168 | + | ) | |
| 169 | + | }) | |
| 170 | + | return _c | |
| 171 | + | } | |
| 172 | + | ||
| 173 | + | func (_c *PendingIssueStore_Count_Call) Return(n int, err error) *PendingIssueStore_Count_Call { | |
| 174 | + | _c.Call.Return(n, err) | |
| 175 | + | return _c | |
| 176 | + | } | |
| 177 | + | ||
| 178 | + | func (_c *PendingIssueStore_Count_Call) RunAndReturn(run func(ctx context.Context) (int, error)) *PendingIssueStore_Count_Call { | |
| 179 | + | _c.Call.Return(run) | |
| 180 | + | return _c | |
| 181 | + | } | |
| 182 | + | ||
| 183 | + | // Delete provides a mock function for the type PendingIssueStore | |
| 184 | + | func (_mock *PendingIssueStore) Delete(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) error { | |
| 185 | + | ret := _mock.Called(ctx, repo, id) | |
| 186 | + | ||
| 187 | + | if len(ret) == 0 { | |
| 188 | + | panic("no return value specified for Delete") | |
| 189 | + | } | |
| 190 | + | ||
| 191 | + | var r0 error | |
| 192 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, domain.PendingIssueID) error); ok { | |
| 193 | + | r0 = returnFunc(ctx, repo, id) | |
| 194 | + | } else { | |
| 195 | + | r0 = ret.Error(0) | |
| 196 | + | } | |
| 197 | + | return r0 | |
| 198 | + | } | |
| 199 | + | ||
| 200 | + | // PendingIssueStore_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' | |
| 201 | + | type PendingIssueStore_Delete_Call struct { | |
| 202 | + | *mock.Call | |
| 203 | + | } | |
| 204 | + | ||
| 205 | + | // Delete is a helper method to define mock.On call | |
| 206 | + | // - ctx context.Context | |
| 207 | + | // - repo domain.RepoName | |
| 208 | + | // - id domain.PendingIssueID | |
| 209 | + | func (_e *PendingIssueStore_Expecter) Delete(ctx any, repo any, id any) *PendingIssueStore_Delete_Call { | |
| 210 | + | return &PendingIssueStore_Delete_Call{Call: _e.mock.On("Delete", ctx, repo, id)} | |
| 211 | + | } | |
| 212 | + | ||
| 213 | + | func (_c *PendingIssueStore_Delete_Call) Run(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID)) *PendingIssueStore_Delete_Call { | |
| 214 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 215 | + | var arg0 context.Context | |
| 216 | + | if args[0] != nil { | |
| 217 | + | arg0 = args[0].(context.Context) | |
| 218 | + | } | |
| 219 | + | var arg1 domain.RepoName | |
| 220 | + | if args[1] != nil { | |
| 221 | + | arg1 = args[1].(domain.RepoName) | |
| 222 | + | } | |
| 223 | + | var arg2 domain.PendingIssueID | |
| 224 | + | if args[2] != nil { | |
| 225 | + | arg2 = args[2].(domain.PendingIssueID) | |
| 226 | + | } | |
| 227 | + | run( | |
| 228 | + | arg0, | |
| 229 | + | arg1, | |
| 230 | + | arg2, | |
| 231 | + | ) | |
| 232 | + | }) | |
| 233 | + | return _c | |
| 234 | + | } | |
| 235 | + | ||
| 236 | + | func (_c *PendingIssueStore_Delete_Call) Return(err error) *PendingIssueStore_Delete_Call { | |
| 237 | + | _c.Call.Return(err) | |
| 238 | + | return _c | |
| 239 | + | } | |
| 240 | + | ||
| 241 | + | func (_c *PendingIssueStore_Delete_Call) RunAndReturn(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) error) *PendingIssueStore_Delete_Call { | |
| 242 | + | _c.Call.Return(run) | |
| 243 | + | return _c | |
| 244 | + | } | |
| 245 | + | ||
| 246 | + | // Get provides a mock function for the type PendingIssueStore | |
| 247 | + | func (_mock *PendingIssueStore) Get(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.PendingIssue, error) { | |
| 248 | + | ret := _mock.Called(ctx, repo, id) | |
| 249 | + | ||
| 250 | + | if len(ret) == 0 { | |
| 251 | + | panic("no return value specified for Get") | |
| 252 | + | } | |
| 253 | + | ||
| 254 | + | var r0 domain.PendingIssue | |
| 255 | + | var r1 error | |
| 256 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, domain.PendingIssueID) (domain.PendingIssue, error)); ok { | |
| 257 | + | return returnFunc(ctx, repo, id) | |
| 258 | + | } | |
| 259 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, domain.PendingIssueID) domain.PendingIssue); ok { | |
| 260 | + | r0 = returnFunc(ctx, repo, id) | |
| 261 | + | } else { | |
| 262 | + | r0 = ret.Get(0).(domain.PendingIssue) | |
| 263 | + | } | |
| 264 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, domain.RepoName, domain.PendingIssueID) error); ok { | |
| 265 | + | r1 = returnFunc(ctx, repo, id) | |
| 266 | + | } else { | |
| 267 | + | r1 = ret.Error(1) | |
| 268 | + | } | |
| 269 | + | return r0, r1 | |
| 270 | + | } | |
| 271 | + | ||
| 272 | + | // PendingIssueStore_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' | |
| 273 | + | type PendingIssueStore_Get_Call struct { | |
| 274 | + | *mock.Call | |
| 275 | + | } | |
| 276 | + | ||
| 277 | + | // Get is a helper method to define mock.On call | |
| 278 | + | // - ctx context.Context | |
| 279 | + | // - repo domain.RepoName | |
| 280 | + | // - id domain.PendingIssueID | |
| 281 | + | func (_e *PendingIssueStore_Expecter) Get(ctx any, repo any, id any) *PendingIssueStore_Get_Call { | |
| 282 | + | return &PendingIssueStore_Get_Call{Call: _e.mock.On("Get", ctx, repo, id)} | |
| 283 | + | } | |
| 284 | + | ||
| 285 | + | func (_c *PendingIssueStore_Get_Call) Run(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID)) *PendingIssueStore_Get_Call { | |
| 286 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 287 | + | var arg0 context.Context | |
| 288 | + | if args[0] != nil { | |
| 289 | + | arg0 = args[0].(context.Context) | |
| 290 | + | } | |
| 291 | + | var arg1 domain.RepoName | |
| 292 | + | if args[1] != nil { | |
| 293 | + | arg1 = args[1].(domain.RepoName) | |
| 294 | + | } | |
| 295 | + | var arg2 domain.PendingIssueID | |
| 296 | + | if args[2] != nil { | |
| 297 | + | arg2 = args[2].(domain.PendingIssueID) | |
| 298 | + | } | |
| 299 | + | run( | |
| 300 | + | arg0, | |
| 301 | + | arg1, | |
| 302 | + | arg2, | |
| 303 | + | ) | |
| 304 | + | }) | |
| 305 | + | return _c | |
| 306 | + | } | |
| 307 | + | ||
| 308 | + | func (_c *PendingIssueStore_Get_Call) Return(pendingIssue domain.PendingIssue, err error) *PendingIssueStore_Get_Call { | |
| 309 | + | _c.Call.Return(pendingIssue, err) | |
| 310 | + | return _c | |
| 311 | + | } | |
| 312 | + | ||
| 313 | + | func (_c *PendingIssueStore_Get_Call) RunAndReturn(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.PendingIssue, error)) *PendingIssueStore_Get_Call { | |
| 314 | + | _c.Call.Return(run) | |
| 315 | + | return _c | |
| 316 | + | } | |
| 317 | + | ||
| 318 | + | // List provides a mock function for the type PendingIssueStore | |
| 319 | + | func (_mock *PendingIssueStore) List(ctx context.Context, repo domain.RepoName, page ports.ListPendingParams) (ports.PendingIssuePage, error) { | |
| 320 | + | ret := _mock.Called(ctx, repo, page) | |
| 321 | + | ||
| 322 | + | if len(ret) == 0 { | |
| 323 | + | panic("no return value specified for List") | |
| 324 | + | } | |
| 325 | + | ||
| 326 | + | var r0 ports.PendingIssuePage | |
| 327 | + | var r1 error | |
| 328 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, ports.ListPendingParams) (ports.PendingIssuePage, error)); ok { | |
| 329 | + | return returnFunc(ctx, repo, page) | |
| 330 | + | } | |
| 331 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, ports.ListPendingParams) ports.PendingIssuePage); ok { | |
| 332 | + | r0 = returnFunc(ctx, repo, page) | |
| 333 | + | } else { | |
| 334 | + | r0 = ret.Get(0).(ports.PendingIssuePage) | |
| 335 | + | } | |
| 336 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, domain.RepoName, ports.ListPendingParams) error); ok { | |
| 337 | + | r1 = returnFunc(ctx, repo, page) | |
| 338 | + | } else { | |
| 339 | + | r1 = ret.Error(1) | |
| 340 | + | } | |
| 341 | + | return r0, r1 | |
| 342 | + | } | |
| 343 | + | ||
| 344 | + | // PendingIssueStore_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' | |
| 345 | + | type PendingIssueStore_List_Call struct { | |
| 346 | + | *mock.Call | |
| 347 | + | } | |
| 348 | + | ||
| 349 | + | // List is a helper method to define mock.On call | |
| 350 | + | // - ctx context.Context | |
| 351 | + | // - repo domain.RepoName | |
| 352 | + | // - page ports.ListPendingParams | |
| 353 | + | func (_e *PendingIssueStore_Expecter) List(ctx any, repo any, page any) *PendingIssueStore_List_Call { | |
| 354 | + | return &PendingIssueStore_List_Call{Call: _e.mock.On("List", ctx, repo, page)} | |
| 355 | + | } | |
| 356 | + | ||
| 357 | + | func (_c *PendingIssueStore_List_Call) Run(run func(ctx context.Context, repo domain.RepoName, page ports.ListPendingParams)) *PendingIssueStore_List_Call { | |
| 358 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 359 | + | var arg0 context.Context | |
| 360 | + | if args[0] != nil { | |
| 361 | + | arg0 = args[0].(context.Context) | |
| 362 | + | } | |
| 363 | + | var arg1 domain.RepoName | |
| 364 | + | if args[1] != nil { | |
| 365 | + | arg1 = args[1].(domain.RepoName) | |
| 366 | + | } | |
| 367 | + | var arg2 ports.ListPendingParams | |
| 368 | + | if args[2] != nil { | |
| 369 | + | arg2 = args[2].(ports.ListPendingParams) | |
| 370 | + | } | |
| 371 | + | run( | |
| 372 | + | arg0, | |
| 373 | + | arg1, | |
| 374 | + | arg2, | |
| 375 | + | ) | |
| 376 | + | }) | |
| 377 | + | return _c | |
| 378 | + | } | |
| 379 | + | ||
| 380 | + | func (_c *PendingIssueStore_List_Call) Return(pendingIssuePage ports.PendingIssuePage, err error) *PendingIssueStore_List_Call { | |
| 381 | + | _c.Call.Return(pendingIssuePage, err) | |
| 382 | + | return _c | |
| 383 | + | } | |
| 384 | + | ||
| 385 | + | func (_c *PendingIssueStore_List_Call) RunAndReturn(run func(ctx context.Context, repo domain.RepoName, page ports.ListPendingParams) (ports.PendingIssuePage, error)) *PendingIssueStore_List_Call { | |
| 386 | + | _c.Call.Return(run) | |
| 387 | + | return _c | |
| 388 | + | } | |
| 389 | + | ||
| 390 | + | // Put provides a mock function for the type PendingIssueStore | |
| 391 | + | func (_mock *PendingIssueStore) Put(ctx context.Context, p domain.PendingIssue) error { | |
| 392 | + | ret := _mock.Called(ctx, p) | |
| 393 | + | ||
| 394 | + | if len(ret) == 0 { | |
| 395 | + | panic("no return value specified for Put") | |
| 396 | + | } | |
| 397 | + | ||
| 398 | + | var r0 error | |
| 399 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.PendingIssue) error); ok { | |
| 400 | + | r0 = returnFunc(ctx, p) | |
| 401 | + | } else { | |
| 402 | + | r0 = ret.Error(0) | |
| 403 | + | } | |
| 404 | + | return r0 | |
| 405 | + | } | |
| 406 | + | ||
| 407 | + | // PendingIssueStore_Put_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Put' | |
| 408 | + | type PendingIssueStore_Put_Call struct { | |
| 409 | + | *mock.Call | |
| 410 | + | } | |
| 411 | + | ||
| 412 | + | // Put is a helper method to define mock.On call | |
| 413 | + | // - ctx context.Context | |
| 414 | + | // - p domain.PendingIssue | |
| 415 | + | func (_e *PendingIssueStore_Expecter) Put(ctx any, p any) *PendingIssueStore_Put_Call { | |
| 416 | + | return &PendingIssueStore_Put_Call{Call: _e.mock.On("Put", ctx, p)} | |
| 417 | + | } | |
| 418 | + | ||
| 419 | + | func (_c *PendingIssueStore_Put_Call) Run(run func(ctx context.Context, p domain.PendingIssue)) *PendingIssueStore_Put_Call { | |
| 420 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 421 | + | var arg0 context.Context | |
| 422 | + | if args[0] != nil { | |
| 423 | + | arg0 = args[0].(context.Context) | |
| 424 | + | } | |
| 425 | + | var arg1 domain.PendingIssue | |
| 426 | + | if args[1] != nil { | |
| 427 | + | arg1 = args[1].(domain.PendingIssue) | |
| 428 | + | } | |
| 429 | + | run( | |
| 430 | + | arg0, | |
| 431 | + | arg1, | |
| 432 | + | ) | |
| 433 | + | }) | |
| 434 | + | return _c | |
| 435 | + | } | |
| 436 | + | ||
| 437 | + | func (_c *PendingIssueStore_Put_Call) Return(err error) *PendingIssueStore_Put_Call { | |
| 438 | + | _c.Call.Return(err) | |
| 439 | + | return _c | |
| 440 | + | } | |
| 441 | + | ||
| 442 | + | func (_c *PendingIssueStore_Put_Call) RunAndReturn(run func(ctx context.Context, p domain.PendingIssue) error) *PendingIssueStore_Put_Call { | |
| 443 | + | _c.Call.Return(run) | |
| 444 | + | return _c | |
| 445 | + | } | |
| @@ -0,0 +1,445 @@ | |||||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |||
| 2 | + | // github.com/vektra/mockery | |||
| 3 | + | // template: testify | |||
| 4 | + | ||||
| 5 | + | package mocks | |||
| 6 | + | ||||
| 7 | + | import ( | |||
| 8 | + | "context" | |||
| 9 | + | ||||
| 10 | + | "bnema.dev/ermite/internal/domain" | |||
| 11 | + | "bnema.dev/ermite/internal/ports" | |||
| 12 | + | mock "github.com/stretchr/testify/mock" | |||
| 13 | + | ) | |||
| 14 | + | ||||
| 15 | + | // NewPendingIssueStore creates a new instance of PendingIssueStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |||
| 16 | + | // The first argument is typically a *testing.T value. | |||
| 17 | + | func NewPendingIssueStore(t interface { | |||
| 18 | + | mock.TestingT | |||
| 19 | + | Cleanup(func()) | |||
| 20 | + | }) *PendingIssueStore { | |||
| 21 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 22 | + | helper.Helper() | |||
| 23 | + | } | |||
| 24 | + | ||||
| 25 | + | mock := &PendingIssueStore{} | |||
| 26 | + | mock.Mock.Test(t) | |||
| 27 | + | ||||
| 28 | + | t.Cleanup(func() { | |||
| 29 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 30 | + | helper.Helper() | |||
| 31 | + | } | |||
| 32 | + | mock.AssertExpectations(t) | |||
| 33 | + | }) | |||
| 34 | + | ||||
| 35 | + | return mock | |||
| 36 | + | } | |||
| 37 | + | ||||
| 38 | + | // PendingIssueStore is an autogenerated mock type for the PendingIssueStore type | |||
| 39 | + | type PendingIssueStore struct { | |||
| 40 | + | mock.Mock | |||
| 41 | + | } | |||
| 42 | + | ||||
| 43 | + | type PendingIssueStore_Expecter struct { | |||
| 44 | + | mock *mock.Mock | |||
| 45 | + | } | |||
| 46 | + | ||||
| 47 | + | func (_m *PendingIssueStore) EXPECT() *PendingIssueStore_Expecter { | |||
| 48 | + | return &PendingIssueStore_Expecter{mock: &_m.Mock} | |||
| 49 | + | } | |||
| 50 | + | ||||
| 51 | + | // Approve provides a mock function for the type PendingIssueStore | |||
| 52 | + | func (_mock *PendingIssueStore) Approve(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error) { | |||
| 53 | + | ret := _mock.Called(ctx, repo, id) | |||
| 54 | + | ||||
| 55 | + | if len(ret) == 0 { | |||
| 56 | + | panic("no return value specified for Approve") | |||
| 57 | + | } | |||
| 58 | + | ||||
| 59 | + | var r0 domain.Issue | |||
| 60 | + | var r1 error | |||
| 61 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, domain.PendingIssueID) (domain.Issue, error)); ok { | |||
| 62 | + | return returnFunc(ctx, repo, id) | |||
| 63 | + | } | |||
| 64 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, domain.PendingIssueID) domain.Issue); ok { | |||
| 65 | + | r0 = returnFunc(ctx, repo, id) | |||
| 66 | + | } else { | |||
| 67 | + | r0 = ret.Get(0).(domain.Issue) | |||
| 68 | + | } | |||
| 69 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, domain.RepoName, domain.PendingIssueID) error); ok { | |||
| 70 | + | r1 = returnFunc(ctx, repo, id) | |||
| 71 | + | } else { | |||
| 72 | + | r1 = ret.Error(1) | |||
| 73 | + | } | |||
| 74 | + | return r0, r1 | |||
| 75 | + | } | |||
| 76 | + | ||||
| 77 | + | // PendingIssueStore_Approve_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Approve' | |||
| 78 | + | type PendingIssueStore_Approve_Call struct { | |||
| 79 | + | *mock.Call | |||
| 80 | + | } | |||
| 81 | + | ||||
| 82 | + | // Approve is a helper method to define mock.On call | |||
| 83 | + | // - ctx context.Context | |||
| 84 | + | // - repo domain.RepoName | |||
| 85 | + | // - id domain.PendingIssueID | |||
| 86 | + | func (_e *PendingIssueStore_Expecter) Approve(ctx any, repo any, id any) *PendingIssueStore_Approve_Call { | |||
| 87 | + | return &PendingIssueStore_Approve_Call{Call: _e.mock.On("Approve", ctx, repo, id)} | |||
| 88 | + | } | |||
| 89 | + | ||||
| 90 | + | func (_c *PendingIssueStore_Approve_Call) Run(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID)) *PendingIssueStore_Approve_Call { | |||
| 91 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 92 | + | var arg0 context.Context | |||
| 93 | + | if args[0] != nil { | |||
| 94 | + | arg0 = args[0].(context.Context) | |||
| 95 | + | } | |||
| 96 | + | var arg1 domain.RepoName | |||
| 97 | + | if args[1] != nil { | |||
| 98 | + | arg1 = args[1].(domain.RepoName) | |||
| 99 | + | } | |||
| 100 | + | var arg2 domain.PendingIssueID | |||
| 101 | + | if args[2] != nil { | |||
| 102 | + | arg2 = args[2].(domain.PendingIssueID) | |||
| 103 | + | } | |||
| 104 | + | run( | |||
| 105 | + | arg0, | |||
| 106 | + | arg1, | |||
| 107 | + | arg2, | |||
| 108 | + | ) | |||
| 109 | + | }) | |||
| 110 | + | return _c | |||
| 111 | + | } | |||
| 112 | + | ||||
| 113 | + | func (_c *PendingIssueStore_Approve_Call) Return(issue domain.Issue, err error) *PendingIssueStore_Approve_Call { | |||
| 114 | + | _c.Call.Return(issue, err) | |||
| 115 | + | return _c | |||
| 116 | + | } | |||
| 117 | + | ||||
| 118 | + | func (_c *PendingIssueStore_Approve_Call) RunAndReturn(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error)) *PendingIssueStore_Approve_Call { | |||
| 119 | + | _c.Call.Return(run) | |||
| 120 | + | return _c | |||
| 121 | + | } | |||
| 122 | + | ||||
| 123 | + | // Count provides a mock function for the type PendingIssueStore | |||
| 124 | + | func (_mock *PendingIssueStore) Count(ctx context.Context) (int, error) { | |||
| 125 | + | ret := _mock.Called(ctx) | |||
| 126 | + | ||||
| 127 | + | if len(ret) == 0 { | |||
| 128 | + | panic("no return value specified for Count") | |||
| 129 | + | } | |||
| 130 | + | ||||
| 131 | + | var r0 int | |||
| 132 | + | var r1 error | |||
| 133 | + | if returnFunc, ok := ret.Get(0).(func(context.Context) (int, error)); ok { | |||
| 134 | + | return returnFunc(ctx) | |||
| 135 | + | } | |||
| 136 | + | if returnFunc, ok := ret.Get(0).(func(context.Context) int); ok { | |||
| 137 | + | r0 = returnFunc(ctx) | |||
| 138 | + | } else { | |||
| 139 | + | r0 = ret.Get(0).(int) | |||
| 140 | + | } | |||
| 141 | + | if returnFunc, ok := ret.Get(1).(func(context.Context) error); ok { | |||
| 142 | + | r1 = returnFunc(ctx) | |||
| 143 | + | } else { | |||
| 144 | + | r1 = ret.Error(1) | |||
| 145 | + | } | |||
| 146 | + | return r0, r1 | |||
| 147 | + | } | |||
| 148 | + | ||||
| 149 | + | // PendingIssueStore_Count_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Count' | |||
| 150 | + | type PendingIssueStore_Count_Call struct { | |||
| 151 | + | *mock.Call | |||
| 152 | + | } | |||
| 153 | + | ||||
| 154 | + | // Count is a helper method to define mock.On call | |||
| 155 | + | // - ctx context.Context | |||
| 156 | + | func (_e *PendingIssueStore_Expecter) Count(ctx any) *PendingIssueStore_Count_Call { | |||
| 157 | + | return &PendingIssueStore_Count_Call{Call: _e.mock.On("Count", ctx)} | |||
| 158 | + | } | |||
| 159 | + | ||||
| 160 | + | func (_c *PendingIssueStore_Count_Call) Run(run func(ctx context.Context)) *PendingIssueStore_Count_Call { | |||
| 161 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 162 | + | var arg0 context.Context | |||
| 163 | + | if args[0] != nil { | |||
| 164 | + | arg0 = args[0].(context.Context) | |||
| 165 | + | } | |||
| 166 | + | run( | |||
| 167 | + | arg0, | |||
| 168 | + | ) | |||
| 169 | + | }) | |||
| 170 | + | return _c | |||
| 171 | + | } | |||
| 172 | + | ||||
| 173 | + | func (_c *PendingIssueStore_Count_Call) Return(n int, err error) *PendingIssueStore_Count_Call { | |||
| 174 | + | _c.Call.Return(n, err) | |||
| 175 | + | return _c | |||
| 176 | + | } | |||
| 177 | + | ||||
| 178 | + | func (_c *PendingIssueStore_Count_Call) RunAndReturn(run func(ctx context.Context) (int, error)) *PendingIssueStore_Count_Call { | |||
| 179 | + | _c.Call.Return(run) | |||
| 180 | + | return _c | |||
| 181 | + | } | |||
| 182 | + | ||||
| 183 | + | // Delete provides a mock function for the type PendingIssueStore | |||
| 184 | + | func (_mock *PendingIssueStore) Delete(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) error { | |||
| 185 | + | ret := _mock.Called(ctx, repo, id) | |||
| 186 | + | ||||
| 187 | + | if len(ret) == 0 { | |||
| 188 | + | panic("no return value specified for Delete") | |||
| 189 | + | } | |||
| 190 | + | ||||
| 191 | + | var r0 error | |||
| 192 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, domain.PendingIssueID) error); ok { | |||
| 193 | + | r0 = returnFunc(ctx, repo, id) | |||
| 194 | + | } else { | |||
| 195 | + | r0 = ret.Error(0) | |||
| 196 | + | } | |||
| 197 | + | return r0 | |||
| 198 | + | } | |||
| 199 | + | ||||
| 200 | + | // PendingIssueStore_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' | |||
| 201 | + | type PendingIssueStore_Delete_Call struct { | |||
| 202 | + | *mock.Call | |||
| 203 | + | } | |||
| 204 | + | ||||
| 205 | + | // Delete is a helper method to define mock.On call | |||
| 206 | + | // - ctx context.Context | |||
| 207 | + | // - repo domain.RepoName | |||
| 208 | + | // - id domain.PendingIssueID | |||
| 209 | + | func (_e *PendingIssueStore_Expecter) Delete(ctx any, repo any, id any) *PendingIssueStore_Delete_Call { | |||
| 210 | + | return &PendingIssueStore_Delete_Call{Call: _e.mock.On("Delete", ctx, repo, id)} | |||
| 211 | + | } | |||
| 212 | + | ||||
| 213 | + | func (_c *PendingIssueStore_Delete_Call) Run(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID)) *PendingIssueStore_Delete_Call { | |||
| 214 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 215 | + | var arg0 context.Context | |||
| 216 | + | if args[0] != nil { | |||
| 217 | + | arg0 = args[0].(context.Context) | |||
| 218 | + | } | |||
| 219 | + | var arg1 domain.RepoName | |||
| 220 | + | if args[1] != nil { | |||
| 221 | + | arg1 = args[1].(domain.RepoName) | |||
| 222 | + | } | |||
| 223 | + | var arg2 domain.PendingIssueID | |||
| 224 | + | if args[2] != nil { | |||
| 225 | + | arg2 = args[2].(domain.PendingIssueID) | |||
| 226 | + | } | |||
| 227 | + | run( | |||
| 228 | + | arg0, | |||
| 229 | + | arg1, | |||
| 230 | + | arg2, | |||
| 231 | + | ) | |||
| 232 | + | }) | |||
| 233 | + | return _c | |||
| 234 | + | } | |||
| 235 | + | ||||
| 236 | + | func (_c *PendingIssueStore_Delete_Call) Return(err error) *PendingIssueStore_Delete_Call { | |||
| 237 | + | _c.Call.Return(err) | |||
| 238 | + | return _c | |||
| 239 | + | } | |||
| 240 | + | ||||
| 241 | + | func (_c *PendingIssueStore_Delete_Call) RunAndReturn(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) error) *PendingIssueStore_Delete_Call { | |||
| 242 | + | _c.Call.Return(run) | |||
| 243 | + | return _c | |||
| 244 | + | } | |||
| 245 | + | ||||
| 246 | + | // Get provides a mock function for the type PendingIssueStore | |||
| 247 | + | func (_mock *PendingIssueStore) Get(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.PendingIssue, error) { | |||
| 248 | + | ret := _mock.Called(ctx, repo, id) | |||
| 249 | + | ||||
| 250 | + | if len(ret) == 0 { | |||
| 251 | + | panic("no return value specified for Get") | |||
| 252 | + | } | |||
| 253 | + | ||||
| 254 | + | var r0 domain.PendingIssue | |||
| 255 | + | var r1 error | |||
| 256 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, domain.PendingIssueID) (domain.PendingIssue, error)); ok { | |||
| 257 | + | return returnFunc(ctx, repo, id) | |||
| 258 | + | } | |||
| 259 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, domain.PendingIssueID) domain.PendingIssue); ok { | |||
| 260 | + | r0 = returnFunc(ctx, repo, id) | |||
| 261 | + | } else { | |||
| 262 | + | r0 = ret.Get(0).(domain.PendingIssue) | |||
| 263 | + | } | |||
| 264 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, domain.RepoName, domain.PendingIssueID) error); ok { | |||
| 265 | + | r1 = returnFunc(ctx, repo, id) | |||
| 266 | + | } else { | |||
| 267 | + | r1 = ret.Error(1) | |||
| 268 | + | } | |||
| 269 | + | return r0, r1 | |||
| 270 | + | } | |||
| 271 | + | ||||
| 272 | + | // PendingIssueStore_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' | |||
| 273 | + | type PendingIssueStore_Get_Call struct { | |||
| 274 | + | *mock.Call | |||
| 275 | + | } | |||
| 276 | + | ||||
| 277 | + | // Get is a helper method to define mock.On call | |||
| 278 | + | // - ctx context.Context | |||
| 279 | + | // - repo domain.RepoName | |||
| 280 | + | // - id domain.PendingIssueID | |||
| 281 | + | func (_e *PendingIssueStore_Expecter) Get(ctx any, repo any, id any) *PendingIssueStore_Get_Call { | |||
| 282 | + | return &PendingIssueStore_Get_Call{Call: _e.mock.On("Get", ctx, repo, id)} | |||
| 283 | + | } | |||
| 284 | + | ||||
| 285 | + | func (_c *PendingIssueStore_Get_Call) Run(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID)) *PendingIssueStore_Get_Call { | |||
| 286 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 287 | + | var arg0 context.Context | |||
| 288 | + | if args[0] != nil { | |||
| 289 | + | arg0 = args[0].(context.Context) | |||
| 290 | + | } | |||
| 291 | + | var arg1 domain.RepoName | |||
| 292 | + | if args[1] != nil { | |||
| 293 | + | arg1 = args[1].(domain.RepoName) | |||
| 294 | + | } | |||
| 295 | + | var arg2 domain.PendingIssueID | |||
| 296 | + | if args[2] != nil { | |||
| 297 | + | arg2 = args[2].(domain.PendingIssueID) | |||
| 298 | + | } | |||
| 299 | + | run( | |||
| 300 | + | arg0, | |||
| 301 | + | arg1, | |||
| 302 | + | arg2, | |||
| 303 | + | ) | |||
| 304 | + | }) | |||
| 305 | + | return _c | |||
| 306 | + | } | |||
| 307 | + | ||||
| 308 | + | func (_c *PendingIssueStore_Get_Call) Return(pendingIssue domain.PendingIssue, err error) *PendingIssueStore_Get_Call { | |||
| 309 | + | _c.Call.Return(pendingIssue, err) | |||
| 310 | + | return _c | |||
| 311 | + | } | |||
| 312 | + | ||||
| 313 | + | func (_c *PendingIssueStore_Get_Call) RunAndReturn(run func(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.PendingIssue, error)) *PendingIssueStore_Get_Call { | |||
| 314 | + | _c.Call.Return(run) | |||
| 315 | + | return _c | |||
| 316 | + | } | |||
| 317 | + | ||||
| 318 | + | // List provides a mock function for the type PendingIssueStore | |||
| 319 | + | func (_mock *PendingIssueStore) List(ctx context.Context, repo domain.RepoName, page ports.ListPendingParams) (ports.PendingIssuePage, error) { | |||
| 320 | + | ret := _mock.Called(ctx, repo, page) | |||
| 321 | + | ||||
| 322 | + | if len(ret) == 0 { | |||
| 323 | + | panic("no return value specified for List") | |||
| 324 | + | } | |||
| 325 | + | ||||
| 326 | + | var r0 ports.PendingIssuePage | |||
| 327 | + | var r1 error | |||
| 328 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, ports.ListPendingParams) (ports.PendingIssuePage, error)); ok { | |||
| 329 | + | return returnFunc(ctx, repo, page) | |||
| 330 | + | } | |||
| 331 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RepoName, ports.ListPendingParams) ports.PendingIssuePage); ok { | |||
| 332 | + | r0 = returnFunc(ctx, repo, page) | |||
| 333 | + | } else { | |||
| 334 | + | r0 = ret.Get(0).(ports.PendingIssuePage) | |||
| 335 | + | } | |||
| 336 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, domain.RepoName, ports.ListPendingParams) error); ok { | |||
| 337 | + | r1 = returnFunc(ctx, repo, page) | |||
| 338 | + | } else { | |||
| 339 | + | r1 = ret.Error(1) | |||
| 340 | + | } | |||
| 341 | + | return r0, r1 | |||
| 342 | + | } | |||
| 343 | + | ||||
| 344 | + | // PendingIssueStore_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' | |||
| 345 | + | type PendingIssueStore_List_Call struct { | |||
| 346 | + | *mock.Call | |||
| 347 | + | } | |||
| 348 | + | ||||
| 349 | + | // List is a helper method to define mock.On call | |||
| 350 | + | // - ctx context.Context | |||
| 351 | + | // - repo domain.RepoName | |||
| 352 | + | // - page ports.ListPendingParams | |||
| 353 | + | func (_e *PendingIssueStore_Expecter) List(ctx any, repo any, page any) *PendingIssueStore_List_Call { | |||
| 354 | + | return &PendingIssueStore_List_Call{Call: _e.mock.On("List", ctx, repo, page)} | |||
| 355 | + | } | |||
| 356 | + | ||||
| 357 | + | func (_c *PendingIssueStore_List_Call) Run(run func(ctx context.Context, repo domain.RepoName, page ports.ListPendingParams)) *PendingIssueStore_List_Call { | |||
| 358 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 359 | + | var arg0 context.Context | |||
| 360 | + | if args[0] != nil { | |||
| 361 | + | arg0 = args[0].(context.Context) | |||
| 362 | + | } | |||
| 363 | + | var arg1 domain.RepoName | |||
| 364 | + | if args[1] != nil { | |||
| 365 | + | arg1 = args[1].(domain.RepoName) | |||
| 366 | + | } | |||
| 367 | + | var arg2 ports.ListPendingParams | |||
| 368 | + | if args[2] != nil { | |||
| 369 | + | arg2 = args[2].(ports.ListPendingParams) | |||
| 370 | + | } | |||
| 371 | + | run( | |||
| 372 | + | arg0, | |||
| 373 | + | arg1, | |||
| 374 | + | arg2, | |||
| 375 | + | ) | |||
| 376 | + | }) | |||
| 377 | + | return _c | |||
| 378 | + | } | |||
| 379 | + | ||||
| 380 | + | func (_c *PendingIssueStore_List_Call) Return(pendingIssuePage ports.PendingIssuePage, err error) *PendingIssueStore_List_Call { | |||
| 381 | + | _c.Call.Return(pendingIssuePage, err) | |||
| 382 | + | return _c | |||
| 383 | + | } | |||
| 384 | + | ||||
| 385 | + | func (_c *PendingIssueStore_List_Call) RunAndReturn(run func(ctx context.Context, repo domain.RepoName, page ports.ListPendingParams) (ports.PendingIssuePage, error)) *PendingIssueStore_List_Call { | |||
| 386 | + | _c.Call.Return(run) | |||
| 387 | + | return _c | |||
| 388 | + | } | |||
| 389 | + | ||||
| 390 | + | // Put provides a mock function for the type PendingIssueStore | |||
| 391 | + | func (_mock *PendingIssueStore) Put(ctx context.Context, p domain.PendingIssue) error { | |||
| 392 | + | ret := _mock.Called(ctx, p) | |||
| 393 | + | ||||
| 394 | + | if len(ret) == 0 { | |||
| 395 | + | panic("no return value specified for Put") | |||
| 396 | + | } | |||
| 397 | + | ||||
| 398 | + | var r0 error | |||
| 399 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, domain.PendingIssue) error); ok { | |||
| 400 | + | r0 = returnFunc(ctx, p) | |||
| 401 | + | } else { | |||
| 402 | + | r0 = ret.Error(0) | |||
| 403 | + | } | |||
| 404 | + | return r0 | |||
| 405 | + | } | |||
| 406 | + | ||||
| 407 | + | // PendingIssueStore_Put_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Put' | |||
| 408 | + | type PendingIssueStore_Put_Call struct { | |||
| 409 | + | *mock.Call | |||
| 410 | + | } | |||
| 411 | + | ||||
| 412 | + | // Put is a helper method to define mock.On call | |||
| 413 | + | // - ctx context.Context | |||
| 414 | + | // - p domain.PendingIssue | |||
| 415 | + | func (_e *PendingIssueStore_Expecter) Put(ctx any, p any) *PendingIssueStore_Put_Call { | |||
| 416 | + | return &PendingIssueStore_Put_Call{Call: _e.mock.On("Put", ctx, p)} | |||
| 417 | + | } | |||
| 418 | + | ||||
| 419 | + | func (_c *PendingIssueStore_Put_Call) Run(run func(ctx context.Context, p domain.PendingIssue)) *PendingIssueStore_Put_Call { | |||
| 420 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 421 | + | var arg0 context.Context | |||
| 422 | + | if args[0] != nil { | |||
| 423 | + | arg0 = args[0].(context.Context) | |||
| 424 | + | } | |||
| 425 | + | var arg1 domain.PendingIssue | |||
| 426 | + | if args[1] != nil { | |||
| 427 | + | arg1 = args[1].(domain.PendingIssue) | |||
| 428 | + | } | |||
| 429 | + | run( | |||
| 430 | + | arg0, | |||
| 431 | + | arg1, | |||
| 432 | + | ) | |||
| 433 | + | }) | |||
| 434 | + | return _c | |||
| 435 | + | } | |||
| 436 | + | ||||
| 437 | + | func (_c *PendingIssueStore_Put_Call) Return(err error) *PendingIssueStore_Put_Call { | |||
| 438 | + | _c.Call.Return(err) | |||
| 439 | + | return _c | |||
| 440 | + | } | |||
| 441 | + | ||||
| 442 | + | func (_c *PendingIssueStore_Put_Call) RunAndReturn(run func(ctx context.Context, p domain.PendingIssue) error) *PendingIssueStore_Put_Call { | |||
| 443 | + | _c.Call.Return(run) | |||
| 444 | + | return _c | |||
| 445 | + | } | |||
A internal/ports/mocks/SubmissionLimiter.go +226 -0
| @@ -0,0 +1,226 @@ | |||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |
| 2 | + | // github.com/vektra/mockery | |
| 3 | + | // template: testify | |
| 4 | + | ||
| 5 | + | package mocks | |
| 6 | + | ||
| 7 | + | import ( | |
| 8 | + | "context" | |
| 9 | + | "time" | |
| 10 | + | ||
| 11 | + | mock "github.com/stretchr/testify/mock" | |
| 12 | + | ) | |
| 13 | + | ||
| 14 | + | // NewSubmissionLimiter creates a new instance of SubmissionLimiter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |
| 15 | + | // The first argument is typically a *testing.T value. | |
| 16 | + | func NewSubmissionLimiter(t interface { | |
| 17 | + | mock.TestingT | |
| 18 | + | Cleanup(func()) | |
| 19 | + | }) *SubmissionLimiter { | |
| 20 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 21 | + | helper.Helper() | |
| 22 | + | } | |
| 23 | + | ||
| 24 | + | mock := &SubmissionLimiter{} | |
| 25 | + | mock.Mock.Test(t) | |
| 26 | + | ||
| 27 | + | t.Cleanup(func() { | |
| 28 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 29 | + | helper.Helper() | |
| 30 | + | } | |
| 31 | + | mock.AssertExpectations(t) | |
| 32 | + | }) | |
| 33 | + | ||
| 34 | + | return mock | |
| 35 | + | } | |
| 36 | + | ||
| 37 | + | // SubmissionLimiter is an autogenerated mock type for the SubmissionLimiter type | |
| 38 | + | type SubmissionLimiter struct { | |
| 39 | + | mock.Mock | |
| 40 | + | } | |
| 41 | + | ||
| 42 | + | type SubmissionLimiter_Expecter struct { | |
| 43 | + | mock *mock.Mock | |
| 44 | + | } | |
| 45 | + | ||
| 46 | + | func (_m *SubmissionLimiter) EXPECT() *SubmissionLimiter_Expecter { | |
| 47 | + | return &SubmissionLimiter_Expecter{mock: &_m.Mock} | |
| 48 | + | } | |
| 49 | + | ||
| 50 | + | // Allow provides a mock function for the type SubmissionLimiter | |
| 51 | + | func (_mock *SubmissionLimiter) Allow(ctx context.Context, addr string) (bool, time.Duration) { | |
| 52 | + | ret := _mock.Called(ctx, addr) | |
| 53 | + | ||
| 54 | + | if len(ret) == 0 { | |
| 55 | + | panic("no return value specified for Allow") | |
| 56 | + | } | |
| 57 | + | ||
| 58 | + | var r0 bool | |
| 59 | + | var r1 time.Duration | |
| 60 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, string) (bool, time.Duration)); ok { | |
| 61 | + | return returnFunc(ctx, addr) | |
| 62 | + | } | |
| 63 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, string) bool); ok { | |
| 64 | + | r0 = returnFunc(ctx, addr) | |
| 65 | + | } else { | |
| 66 | + | r0 = ret.Get(0).(bool) | |
| 67 | + | } | |
| 68 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, string) time.Duration); ok { | |
| 69 | + | r1 = returnFunc(ctx, addr) | |
| 70 | + | } else { | |
| 71 | + | r1 = ret.Get(1).(time.Duration) | |
| 72 | + | } | |
| 73 | + | return r0, r1 | |
| 74 | + | } | |
| 75 | + | ||
| 76 | + | // SubmissionLimiter_Allow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Allow' | |
| 77 | + | type SubmissionLimiter_Allow_Call struct { | |
| 78 | + | *mock.Call | |
| 79 | + | } | |
| 80 | + | ||
| 81 | + | // Allow is a helper method to define mock.On call | |
| 82 | + | // - ctx context.Context | |
| 83 | + | // - addr string | |
| 84 | + | func (_e *SubmissionLimiter_Expecter) Allow(ctx any, addr any) *SubmissionLimiter_Allow_Call { | |
| 85 | + | return &SubmissionLimiter_Allow_Call{Call: _e.mock.On("Allow", ctx, addr)} | |
| 86 | + | } | |
| 87 | + | ||
| 88 | + | func (_c *SubmissionLimiter_Allow_Call) Run(run func(ctx context.Context, addr string)) *SubmissionLimiter_Allow_Call { | |
| 89 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 90 | + | var arg0 context.Context | |
| 91 | + | if args[0] != nil { | |
| 92 | + | arg0 = args[0].(context.Context) | |
| 93 | + | } | |
| 94 | + | var arg1 string | |
| 95 | + | if args[1] != nil { | |
| 96 | + | arg1 = args[1].(string) | |
| 97 | + | } | |
| 98 | + | run( | |
| 99 | + | arg0, | |
| 100 | + | arg1, | |
| 101 | + | ) | |
| 102 | + | }) | |
| 103 | + | return _c | |
| 104 | + | } | |
| 105 | + | ||
| 106 | + | func (_c *SubmissionLimiter_Allow_Call) Return(ok bool, retryAfter time.Duration) *SubmissionLimiter_Allow_Call { | |
| 107 | + | _c.Call.Return(ok, retryAfter) | |
| 108 | + | return _c | |
| 109 | + | } | |
| 110 | + | ||
| 111 | + | func (_c *SubmissionLimiter_Allow_Call) RunAndReturn(run func(ctx context.Context, addr string) (bool, time.Duration)) *SubmissionLimiter_Allow_Call { | |
| 112 | + | _c.Call.Return(run) | |
| 113 | + | return _c | |
| 114 | + | } | |
| 115 | + | ||
| 116 | + | // Recent provides a mock function for the type SubmissionLimiter | |
| 117 | + | func (_mock *SubmissionLimiter) Recent(ctx context.Context, addr string) (int, int) { | |
| 118 | + | ret := _mock.Called(ctx, addr) | |
| 119 | + | ||
| 120 | + | if len(ret) == 0 { | |
| 121 | + | panic("no return value specified for Recent") | |
| 122 | + | } | |
| 123 | + | ||
| 124 | + | var r0 int | |
| 125 | + | var r1 int | |
| 126 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, string) (int, int)); ok { | |
| 127 | + | return returnFunc(ctx, addr) | |
| 128 | + | } | |
| 129 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, string) int); ok { | |
| 130 | + | r0 = returnFunc(ctx, addr) | |
| 131 | + | } else { | |
| 132 | + | r0 = ret.Get(0).(int) | |
| 133 | + | } | |
| 134 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, string) int); ok { | |
| 135 | + | r1 = returnFunc(ctx, addr) | |
| 136 | + | } else { | |
| 137 | + | r1 = ret.Get(1).(int) | |
| 138 | + | } | |
| 139 | + | return r0, r1 | |
| 140 | + | } | |
| 141 | + | ||
| 142 | + | // SubmissionLimiter_Recent_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Recent' | |
| 143 | + | type SubmissionLimiter_Recent_Call struct { | |
| 144 | + | *mock.Call | |
| 145 | + | } | |
| 146 | + | ||
| 147 | + | // Recent is a helper method to define mock.On call | |
| 148 | + | // - ctx context.Context | |
| 149 | + | // - addr string | |
| 150 | + | func (_e *SubmissionLimiter_Expecter) Recent(ctx any, addr any) *SubmissionLimiter_Recent_Call { | |
| 151 | + | return &SubmissionLimiter_Recent_Call{Call: _e.mock.On("Recent", ctx, addr)} | |
| 152 | + | } | |
| 153 | + | ||
| 154 | + | func (_c *SubmissionLimiter_Recent_Call) Run(run func(ctx context.Context, addr string)) *SubmissionLimiter_Recent_Call { | |
| 155 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 156 | + | var arg0 context.Context | |
| 157 | + | if args[0] != nil { | |
| 158 | + | arg0 = args[0].(context.Context) | |
| 159 | + | } | |
| 160 | + | var arg1 string | |
| 161 | + | if args[1] != nil { | |
| 162 | + | arg1 = args[1].(string) | |
| 163 | + | } | |
| 164 | + | run( | |
| 165 | + | arg0, | |
| 166 | + | arg1, | |
| 167 | + | ) | |
| 168 | + | }) | |
| 169 | + | return _c | |
| 170 | + | } | |
| 171 | + | ||
| 172 | + | func (_c *SubmissionLimiter_Recent_Call) Return(perAddr int, global int) *SubmissionLimiter_Recent_Call { | |
| 173 | + | _c.Call.Return(perAddr, global) | |
| 174 | + | return _c | |
| 175 | + | } | |
| 176 | + | ||
| 177 | + | func (_c *SubmissionLimiter_Recent_Call) RunAndReturn(run func(ctx context.Context, addr string) (int, int)) *SubmissionLimiter_Recent_Call { | |
| 178 | + | _c.Call.Return(run) | |
| 179 | + | return _c | |
| 180 | + | } | |
| 181 | + | ||
| 182 | + | // Record provides a mock function for the type SubmissionLimiter | |
| 183 | + | func (_mock *SubmissionLimiter) Record(ctx context.Context, addr string) { | |
| 184 | + | _mock.Called(ctx, addr) | |
| 185 | + | return | |
| 186 | + | } | |
| 187 | + | ||
| 188 | + | // SubmissionLimiter_Record_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Record' | |
| 189 | + | type SubmissionLimiter_Record_Call struct { | |
| 190 | + | *mock.Call | |
| 191 | + | } | |
| 192 | + | ||
| 193 | + | // Record is a helper method to define mock.On call | |
| 194 | + | // - ctx context.Context | |
| 195 | + | // - addr string | |
| 196 | + | func (_e *SubmissionLimiter_Expecter) Record(ctx any, addr any) *SubmissionLimiter_Record_Call { | |
| 197 | + | return &SubmissionLimiter_Record_Call{Call: _e.mock.On("Record", ctx, addr)} | |
| 198 | + | } | |
| 199 | + | ||
| 200 | + | func (_c *SubmissionLimiter_Record_Call) Run(run func(ctx context.Context, addr string)) *SubmissionLimiter_Record_Call { | |
| 201 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 202 | + | var arg0 context.Context | |
| 203 | + | if args[0] != nil { | |
| 204 | + | arg0 = args[0].(context.Context) | |
| 205 | + | } | |
| 206 | + | var arg1 string | |
| 207 | + | if args[1] != nil { | |
| 208 | + | arg1 = args[1].(string) | |
| 209 | + | } | |
| 210 | + | run( | |
| 211 | + | arg0, | |
| 212 | + | arg1, | |
| 213 | + | ) | |
| 214 | + | }) | |
| 215 | + | return _c | |
| 216 | + | } | |
| 217 | + | ||
| 218 | + | func (_c *SubmissionLimiter_Record_Call) Return() *SubmissionLimiter_Record_Call { | |
| 219 | + | _c.Call.Return() | |
| 220 | + | return _c | |
| 221 | + | } | |
| 222 | + | ||
| 223 | + | func (_c *SubmissionLimiter_Record_Call) RunAndReturn(run func(ctx context.Context, addr string)) *SubmissionLimiter_Record_Call { | |
| 224 | + | _c.Run(run) | |
| 225 | + | return _c | |
| 226 | + | } | |
| @@ -0,0 +1,226 @@ | |||||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |||
| 2 | + | // github.com/vektra/mockery | |||
| 3 | + | // template: testify | |||
| 4 | + | ||||
| 5 | + | package mocks | |||
| 6 | + | ||||
| 7 | + | import ( | |||
| 8 | + | "context" | |||
| 9 | + | "time" | |||
| 10 | + | ||||
| 11 | + | mock "github.com/stretchr/testify/mock" | |||
| 12 | + | ) | |||
| 13 | + | ||||
| 14 | + | // NewSubmissionLimiter creates a new instance of SubmissionLimiter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |||
| 15 | + | // The first argument is typically a *testing.T value. | |||
| 16 | + | func NewSubmissionLimiter(t interface { | |||
| 17 | + | mock.TestingT | |||
| 18 | + | Cleanup(func()) | |||
| 19 | + | }) *SubmissionLimiter { | |||
| 20 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 21 | + | helper.Helper() | |||
| 22 | + | } | |||
| 23 | + | ||||
| 24 | + | mock := &SubmissionLimiter{} | |||
| 25 | + | mock.Mock.Test(t) | |||
| 26 | + | ||||
| 27 | + | t.Cleanup(func() { | |||
| 28 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 29 | + | helper.Helper() | |||
| 30 | + | } | |||
| 31 | + | mock.AssertExpectations(t) | |||
| 32 | + | }) | |||
| 33 | + | ||||
| 34 | + | return mock | |||
| 35 | + | } | |||
| 36 | + | ||||
| 37 | + | // SubmissionLimiter is an autogenerated mock type for the SubmissionLimiter type | |||
| 38 | + | type SubmissionLimiter struct { | |||
| 39 | + | mock.Mock | |||
| 40 | + | } | |||
| 41 | + | ||||
| 42 | + | type SubmissionLimiter_Expecter struct { | |||
| 43 | + | mock *mock.Mock | |||
| 44 | + | } | |||
| 45 | + | ||||
| 46 | + | func (_m *SubmissionLimiter) EXPECT() *SubmissionLimiter_Expecter { | |||
| 47 | + | return &SubmissionLimiter_Expecter{mock: &_m.Mock} | |||
| 48 | + | } | |||
| 49 | + | ||||
| 50 | + | // Allow provides a mock function for the type SubmissionLimiter | |||
| 51 | + | func (_mock *SubmissionLimiter) Allow(ctx context.Context, addr string) (bool, time.Duration) { | |||
| 52 | + | ret := _mock.Called(ctx, addr) | |||
| 53 | + | ||||
| 54 | + | if len(ret) == 0 { | |||
| 55 | + | panic("no return value specified for Allow") | |||
| 56 | + | } | |||
| 57 | + | ||||
| 58 | + | var r0 bool | |||
| 59 | + | var r1 time.Duration | |||
| 60 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, string) (bool, time.Duration)); ok { | |||
| 61 | + | return returnFunc(ctx, addr) | |||
| 62 | + | } | |||
| 63 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, string) bool); ok { | |||
| 64 | + | r0 = returnFunc(ctx, addr) | |||
| 65 | + | } else { | |||
| 66 | + | r0 = ret.Get(0).(bool) | |||
| 67 | + | } | |||
| 68 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, string) time.Duration); ok { | |||
| 69 | + | r1 = returnFunc(ctx, addr) | |||
| 70 | + | } else { | |||
| 71 | + | r1 = ret.Get(1).(time.Duration) | |||
| 72 | + | } | |||
| 73 | + | return r0, r1 | |||
| 74 | + | } | |||
| 75 | + | ||||
| 76 | + | // SubmissionLimiter_Allow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Allow' | |||
| 77 | + | type SubmissionLimiter_Allow_Call struct { | |||
| 78 | + | *mock.Call | |||
| 79 | + | } | |||
| 80 | + | ||||
| 81 | + | // Allow is a helper method to define mock.On call | |||
| 82 | + | // - ctx context.Context | |||
| 83 | + | // - addr string | |||
| 84 | + | func (_e *SubmissionLimiter_Expecter) Allow(ctx any, addr any) *SubmissionLimiter_Allow_Call { | |||
| 85 | + | return &SubmissionLimiter_Allow_Call{Call: _e.mock.On("Allow", ctx, addr)} | |||
| 86 | + | } | |||
| 87 | + | ||||
| 88 | + | func (_c *SubmissionLimiter_Allow_Call) Run(run func(ctx context.Context, addr string)) *SubmissionLimiter_Allow_Call { | |||
| 89 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 90 | + | var arg0 context.Context | |||
| 91 | + | if args[0] != nil { | |||
| 92 | + | arg0 = args[0].(context.Context) | |||
| 93 | + | } | |||
| 94 | + | var arg1 string | |||
| 95 | + | if args[1] != nil { | |||
| 96 | + | arg1 = args[1].(string) | |||
| 97 | + | } | |||
| 98 | + | run( | |||
| 99 | + | arg0, | |||
| 100 | + | arg1, | |||
| 101 | + | ) | |||
| 102 | + | }) | |||
| 103 | + | return _c | |||
| 104 | + | } | |||
| 105 | + | ||||
| 106 | + | func (_c *SubmissionLimiter_Allow_Call) Return(ok bool, retryAfter time.Duration) *SubmissionLimiter_Allow_Call { | |||
| 107 | + | _c.Call.Return(ok, retryAfter) | |||
| 108 | + | return _c | |||
| 109 | + | } | |||
| 110 | + | ||||
| 111 | + | func (_c *SubmissionLimiter_Allow_Call) RunAndReturn(run func(ctx context.Context, addr string) (bool, time.Duration)) *SubmissionLimiter_Allow_Call { | |||
| 112 | + | _c.Call.Return(run) | |||
| 113 | + | return _c | |||
| 114 | + | } | |||
| 115 | + | ||||
| 116 | + | // Recent provides a mock function for the type SubmissionLimiter | |||
| 117 | + | func (_mock *SubmissionLimiter) Recent(ctx context.Context, addr string) (int, int) { | |||
| 118 | + | ret := _mock.Called(ctx, addr) | |||
| 119 | + | ||||
| 120 | + | if len(ret) == 0 { | |||
| 121 | + | panic("no return value specified for Recent") | |||
| 122 | + | } | |||
| 123 | + | ||||
| 124 | + | var r0 int | |||
| 125 | + | var r1 int | |||
| 126 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, string) (int, int)); ok { | |||
| 127 | + | return returnFunc(ctx, addr) | |||
| 128 | + | } | |||
| 129 | + | if returnFunc, ok := ret.Get(0).(func(context.Context, string) int); ok { | |||
| 130 | + | r0 = returnFunc(ctx, addr) | |||
| 131 | + | } else { | |||
| 132 | + | r0 = ret.Get(0).(int) | |||
| 133 | + | } | |||
| 134 | + | if returnFunc, ok := ret.Get(1).(func(context.Context, string) int); ok { | |||
| 135 | + | r1 = returnFunc(ctx, addr) | |||
| 136 | + | } else { | |||
| 137 | + | r1 = ret.Get(1).(int) | |||
| 138 | + | } | |||
| 139 | + | return r0, r1 | |||
| 140 | + | } | |||
| 141 | + | ||||
| 142 | + | // SubmissionLimiter_Recent_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Recent' | |||
| 143 | + | type SubmissionLimiter_Recent_Call struct { | |||
| 144 | + | *mock.Call | |||
| 145 | + | } | |||
| 146 | + | ||||
| 147 | + | // Recent is a helper method to define mock.On call | |||
| 148 | + | // - ctx context.Context | |||
| 149 | + | // - addr string | |||
| 150 | + | func (_e *SubmissionLimiter_Expecter) Recent(ctx any, addr any) *SubmissionLimiter_Recent_Call { | |||
| 151 | + | return &SubmissionLimiter_Recent_Call{Call: _e.mock.On("Recent", ctx, addr)} | |||
| 152 | + | } | |||
| 153 | + | ||||
| 154 | + | func (_c *SubmissionLimiter_Recent_Call) Run(run func(ctx context.Context, addr string)) *SubmissionLimiter_Recent_Call { | |||
| 155 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 156 | + | var arg0 context.Context | |||
| 157 | + | if args[0] != nil { | |||
| 158 | + | arg0 = args[0].(context.Context) | |||
| 159 | + | } | |||
| 160 | + | var arg1 string | |||
| 161 | + | if args[1] != nil { | |||
| 162 | + | arg1 = args[1].(string) | |||
| 163 | + | } | |||
| 164 | + | run( | |||
| 165 | + | arg0, | |||
| 166 | + | arg1, | |||
| 167 | + | ) | |||
| 168 | + | }) | |||
| 169 | + | return _c | |||
| 170 | + | } | |||
| 171 | + | ||||
| 172 | + | func (_c *SubmissionLimiter_Recent_Call) Return(perAddr int, global int) *SubmissionLimiter_Recent_Call { | |||
| 173 | + | _c.Call.Return(perAddr, global) | |||
| 174 | + | return _c | |||
| 175 | + | } | |||
| 176 | + | ||||
| 177 | + | func (_c *SubmissionLimiter_Recent_Call) RunAndReturn(run func(ctx context.Context, addr string) (int, int)) *SubmissionLimiter_Recent_Call { | |||
| 178 | + | _c.Call.Return(run) | |||
| 179 | + | return _c | |||
| 180 | + | } | |||
| 181 | + | ||||
| 182 | + | // Record provides a mock function for the type SubmissionLimiter | |||
| 183 | + | func (_mock *SubmissionLimiter) Record(ctx context.Context, addr string) { | |||
| 184 | + | _mock.Called(ctx, addr) | |||
| 185 | + | return | |||
| 186 | + | } | |||
| 187 | + | ||||
| 188 | + | // SubmissionLimiter_Record_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Record' | |||
| 189 | + | type SubmissionLimiter_Record_Call struct { | |||
| 190 | + | *mock.Call | |||
| 191 | + | } | |||
| 192 | + | ||||
| 193 | + | // Record is a helper method to define mock.On call | |||
| 194 | + | // - ctx context.Context | |||
| 195 | + | // - addr string | |||
| 196 | + | func (_e *SubmissionLimiter_Expecter) Record(ctx any, addr any) *SubmissionLimiter_Record_Call { | |||
| 197 | + | return &SubmissionLimiter_Record_Call{Call: _e.mock.On("Record", ctx, addr)} | |||
| 198 | + | } | |||
| 199 | + | ||||
| 200 | + | func (_c *SubmissionLimiter_Record_Call) Run(run func(ctx context.Context, addr string)) *SubmissionLimiter_Record_Call { | |||
| 201 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 202 | + | var arg0 context.Context | |||
| 203 | + | if args[0] != nil { | |||
| 204 | + | arg0 = args[0].(context.Context) | |||
| 205 | + | } | |||
| 206 | + | var arg1 string | |||
| 207 | + | if args[1] != nil { | |||
| 208 | + | arg1 = args[1].(string) | |||
| 209 | + | } | |||
| 210 | + | run( | |||
| 211 | + | arg0, | |||
| 212 | + | arg1, | |||
| 213 | + | ) | |||
| 214 | + | }) | |||
| 215 | + | return _c | |||
| 216 | + | } | |||
| 217 | + | ||||
| 218 | + | func (_c *SubmissionLimiter_Record_Call) Return() *SubmissionLimiter_Record_Call { | |||
| 219 | + | _c.Call.Return() | |||
| 220 | + | return _c | |||
| 221 | + | } | |||
| 222 | + | ||||
| 223 | + | func (_c *SubmissionLimiter_Record_Call) RunAndReturn(run func(ctx context.Context, addr string)) *SubmissionLimiter_Record_Call { | |||
| 224 | + | _c.Run(run) | |||
| 225 | + | return _c | |||
| 226 | + | } | |||
M internal/ports/ports.go +43 -0
| @@ -278,6 +278,49 @@ type IssueStore interface { | |||
| 278 | 278 | ListComments(ctx context.Context, repo domain.RepoName, number int64) ([]domain.IssueComment, error) | |
| 279 | 279 | } | |
| 280 | 280 | ||
| 281 | + | // PendingIssueStore keeps the issues submitted through the public form until | |
| 282 | + | // the owner decides. They have no number: Approve gives one. Put and Approve | |
| 283 | + | // return domain.ErrNotFound when the repository does not exist, so that | |
| 284 | + | // deleting a repository leaves nothing for one created again under its name. | |
| 285 | + | // *kvstore.PendingIssues implements it. | |
| 286 | + | type PendingIssueStore interface { | |
| 287 | + | // Put stores the pending issue; its id must be new. | |
| 288 | + | Put(ctx context.Context, p domain.PendingIssue) error | |
| 289 | + | // Get returns the pending issue, or domain.ErrNotFound. | |
| 290 | + | Get(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.PendingIssue, error) | |
| 291 | + | // List returns a page of the pending issues of the repository, or of | |
| 292 | + | // every repository when repo is zero, oldest first. A PageSize of 0 | |
| 293 | + | // means every one. | |
| 294 | + | List(ctx context.Context, repo domain.RepoName, page ListPendingParams) (PendingIssuePage, error) | |
| 295 | + | // Count returns how many pending issues there are in all repositories, | |
| 296 | + | // reading at most domain.MaxPendingIssues+1 of them. | |
| 297 | + | Count(ctx context.Context) (int, error) | |
| 298 | + | // Approve takes the next number of the repository (the one merge requests | |
| 299 | + | // and issues share), writes the open issue (its author is the pending | |
| 300 | + | // one, or "anonymous"), indexes it as open and deletes the pending record, | |
| 301 | + | // in one batch. It returns domain.ErrNotFound when either is missing. | |
| 302 | + | Approve(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error) | |
| 303 | + | // Delete removes the pending issue, or returns domain.ErrNotFound. | |
| 304 | + | Delete(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) error | |
| 305 | + | } | |
| 306 | + | ||
| 307 | + | // IssueKeyStore keeps the server key of the public issue form, from which the | |
| 308 | + | // use cases derive their subkeys. | |
| 309 | + | type IssueKeyStore interface { | |
| 310 | + | // Key returns the 32-byte secret. The first call on an empty store | |
| 311 | + | // generates and stores it; a restart keeps it. | |
| 312 | + | Key(ctx context.Context) ([]byte, error) | |
| 313 | + | } | |
| 314 | + | ||
| 315 | + | // IssueBanStore keeps the bans of submitters, by the hash of their client key. | |
| 316 | + | type IssueBanStore interface { | |
| 317 | + | // Ban bans the hash until the given time, replacing an earlier ban. | |
| 318 | + | Ban(ctx context.Context, hash []byte, until time.Time) error | |
| 319 | + | // Banned reports whether the hash is banned at now. An expired ban counts | |
| 320 | + | // as not banned and is deleted. | |
| 321 | + | Banned(ctx context.Context, hash []byte, now time.Time) (bool, error) | |
| 322 | + | } | |
| 323 | + | ||
| 281 | 324 | // MergeRequestStore keeps the merge requests of the repositories, their | |
| 282 | 325 | // comments and the read position of the reviewer. A repository has no entry | |
| 283 | 326 | // until its first merge request. Create, SaveComment and SetRead return | |
| @@ -278,6 +278,49 @@ type IssueStore interface { | |||||
| 278 | ListComments(ctx context.Context, repo domain.RepoName, number int64) ([]domain.IssueComment, error) | 278 | ListComments(ctx context.Context, repo domain.RepoName, number int64) ([]domain.IssueComment, error) | ||
| 279 | } | 279 | } | ||
| 280 | 280 | ||||
| 281 | + | // PendingIssueStore keeps the issues submitted through the public form until | |||
| 282 | + | // the owner decides. They have no number: Approve gives one. Put and Approve | |||
| 283 | + | // return domain.ErrNotFound when the repository does not exist, so that | |||
| 284 | + | // deleting a repository leaves nothing for one created again under its name. | |||
| 285 | + | // *kvstore.PendingIssues implements it. | |||
| 286 | + | type PendingIssueStore interface { | |||
| 287 | + | // Put stores the pending issue; its id must be new. | |||
| 288 | + | Put(ctx context.Context, p domain.PendingIssue) error | |||
| 289 | + | // Get returns the pending issue, or domain.ErrNotFound. | |||
| 290 | + | Get(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.PendingIssue, error) | |||
| 291 | + | // List returns a page of the pending issues of the repository, or of | |||
| 292 | + | // every repository when repo is zero, oldest first. A PageSize of 0 | |||
| 293 | + | // means every one. | |||
| 294 | + | List(ctx context.Context, repo domain.RepoName, page ListPendingParams) (PendingIssuePage, error) | |||
| 295 | + | // Count returns how many pending issues there are in all repositories, | |||
| 296 | + | // reading at most domain.MaxPendingIssues+1 of them. | |||
| 297 | + | Count(ctx context.Context) (int, error) | |||
| 298 | + | // Approve takes the next number of the repository (the one merge requests | |||
| 299 | + | // and issues share), writes the open issue (its author is the pending | |||
| 300 | + | // one, or "anonymous"), indexes it as open and deletes the pending record, | |||
| 301 | + | // in one batch. It returns domain.ErrNotFound when either is missing. | |||
| 302 | + | Approve(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error) | |||
| 303 | + | // Delete removes the pending issue, or returns domain.ErrNotFound. | |||
| 304 | + | Delete(ctx context.Context, repo domain.RepoName, id domain.PendingIssueID) error | |||
| 305 | + | } | |||
| 306 | + | ||||
| 307 | + | // IssueKeyStore keeps the server key of the public issue form, from which the | |||
| 308 | + | // use cases derive their subkeys. | |||
| 309 | + | type IssueKeyStore interface { | |||
| 310 | + | // Key returns the 32-byte secret. The first call on an empty store | |||
| 311 | + | // generates and stores it; a restart keeps it. | |||
| 312 | + | Key(ctx context.Context) ([]byte, error) | |||
| 313 | + | } | |||
| 314 | + | ||||
| 315 | + | // IssueBanStore keeps the bans of submitters, by the hash of their client key. | |||
| 316 | + | type IssueBanStore interface { | |||
| 317 | + | // Ban bans the hash until the given time, replacing an earlier ban. | |||
| 318 | + | Ban(ctx context.Context, hash []byte, until time.Time) error | |||
| 319 | + | // Banned reports whether the hash is banned at now. An expired ban counts | |||
| 320 | + | // as not banned and is deleted. | |||
| 321 | + | Banned(ctx context.Context, hash []byte, now time.Time) (bool, error) | |||
| 322 | + | } | |||
| 323 | + | ||||
| 281 | // MergeRequestStore keeps the merge requests of the repositories, their | 324 | // MergeRequestStore keeps the merge requests of the repositories, their | ||
| 282 | // comments and the read position of the reviewer. A repository has no entry | 325 | // comments and the read position of the reviewer. A repository has no entry | ||
| 283 | // until its first merge request. Create, SaveComment and SetRead return | 326 | // until its first merge request. Create, SaveComment and SetRead return | ||
M internal/ports/services.go +25 -0
| @@ -135,6 +135,19 @@ type IssueService interface { | |||
| 135 | 135 | Reopen(ctx context.Context, p domain.Principal, name domain.RepoName, number int64) (domain.Issue, error) | |
| 136 | 136 | } | |
| 137 | 137 | ||
| 138 | + | // IssueModerationService is the owner's moderation of the pending issues. | |
| 139 | + | // Every call needs owner rights and answers domain.ErrNotFound otherwise. | |
| 140 | + | // *usecase.IssueModeration implements it. | |
| 141 | + | type IssueModerationService interface { | |
| 142 | + | // ListPending lists the pending issues of a repository, or of every | |
| 143 | + | // repository when repo is zero, oldest first. | |
| 144 | + | ListPending(ctx context.Context, p domain.Principal, repo domain.RepoName, page ListPendingParams) (PendingIssuePage, error) | |
| 145 | + | // Approve opens the pending issue under a new number. | |
| 146 | + | Approve(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error) | |
| 147 | + | // Reject deletes the pending issue and, with ban, bans its submitter. | |
| 148 | + | Reject(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID, ban bool) error | |
| 149 | + | } | |
| 150 | + | ||
| 138 | 151 | // IssueNumberResolver tells whether a number of a repository names an issue or | |
| 139 | 152 | // a merge request, for the callers that follow a "#n" reference. *usecase.Issues | |
| 140 | 153 | // implements it. | |
| @@ -265,6 +278,18 @@ type FailureLimiter interface { | |||
| 265 | 278 | Fail(ctx context.Context, addr string) | |
| 266 | 279 | } | |
| 267 | 280 | ||
| 281 | + | // SubmissionLimiter limits the submissions of the public issue form per | |
| 282 | + | // client. *clientlimit.SubmissionLimiter implements it. | |
| 283 | + | type SubmissionLimiter interface { | |
| 284 | + | // Allow reports whether addr may submit now, and when to retry if not. | |
| 285 | + | Allow(ctx context.Context, addr string) (ok bool, retryAfter time.Duration) | |
| 286 | + | // Record counts a submission from addr. | |
| 287 | + | Record(ctx context.Context, addr string) | |
| 288 | + | // Recent returns the submissions of the last hour from addr and from all | |
| 289 | + | // clients. | |
| 290 | + | Recent(ctx context.Context, addr string) (perAddr, global int) | |
| 291 | + | } | |
| 292 | + | ||
| 268 | 293 | // SecretPage is one page of secrets. | |
| 269 | 294 | type SecretPage struct { | |
| 270 | 295 | Secrets []domain.Secret | |
| @@ -135,6 +135,19 @@ type IssueService interface { | |||||
| 135 | Reopen(ctx context.Context, p domain.Principal, name domain.RepoName, number int64) (domain.Issue, error) | 135 | Reopen(ctx context.Context, p domain.Principal, name domain.RepoName, number int64) (domain.Issue, error) | ||
| 136 | } | 136 | } | ||
| 137 | 137 | ||||
| 138 | + | // IssueModerationService is the owner's moderation of the pending issues. | |||
| 139 | + | // Every call needs owner rights and answers domain.ErrNotFound otherwise. | |||
| 140 | + | // *usecase.IssueModeration implements it. | |||
| 141 | + | type IssueModerationService interface { | |||
| 142 | + | // ListPending lists the pending issues of a repository, or of every | |||
| 143 | + | // repository when repo is zero, oldest first. | |||
| 144 | + | ListPending(ctx context.Context, p domain.Principal, repo domain.RepoName, page ListPendingParams) (PendingIssuePage, error) | |||
| 145 | + | // Approve opens the pending issue under a new number. | |||
| 146 | + | Approve(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID) (domain.Issue, error) | |||
| 147 | + | // Reject deletes the pending issue and, with ban, bans its submitter. | |||
| 148 | + | Reject(ctx context.Context, p domain.Principal, repo domain.RepoName, id domain.PendingIssueID, ban bool) error | |||
| 149 | + | } | |||
| 150 | + | ||||
| 138 | // IssueNumberResolver tells whether a number of a repository names an issue or | 151 | // IssueNumberResolver tells whether a number of a repository names an issue or | ||
| 139 | // a merge request, for the callers that follow a "#n" reference. *usecase.Issues | 152 | // a merge request, for the callers that follow a "#n" reference. *usecase.Issues | ||
| 140 | // implements it. | 153 | // implements it. | ||
| @@ -265,6 +278,18 @@ type FailureLimiter interface { | |||||
| 265 | Fail(ctx context.Context, addr string) | 278 | Fail(ctx context.Context, addr string) | ||
| 266 | } | 279 | } | ||
| 267 | 280 | ||||
| 281 | + | // SubmissionLimiter limits the submissions of the public issue form per | |||
| 282 | + | // client. *clientlimit.SubmissionLimiter implements it. | |||
| 283 | + | type SubmissionLimiter interface { | |||
| 284 | + | // Allow reports whether addr may submit now, and when to retry if not. | |||
| 285 | + | Allow(ctx context.Context, addr string) (ok bool, retryAfter time.Duration) | |||
| 286 | + | // Record counts a submission from addr. | |||
| 287 | + | Record(ctx context.Context, addr string) | |||
| 288 | + | // Recent returns the submissions of the last hour from addr and from all | |||
| 289 | + | // clients. | |||
| 290 | + | Recent(ctx context.Context, addr string) (perAddr, global int) | |||
| 291 | + | } | |||
| 292 | + | ||||
| 268 | // SecretPage is one page of secrets. | 293 | // SecretPage is one page of secrets. | ||
| 269 | type SecretPage struct { | 294 | type SecretPage struct { | ||
| 270 | Secrets []domain.Secret | 295 | Secrets []domain.Secret | ||