mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-06-22 10:02:15 +00:00
introduce sentinel error when pr has no poster
This commit is contained in:
parent
4a546861ee
commit
1fb011c4ea
3 changed files with 6 additions and 3 deletions
|
|
@ -80,7 +80,10 @@ func (err ErrIssueWasClosed) Error() string {
|
|||
return fmt.Sprintf("Issue [%d] %d was already closed", err.ID, err.Index)
|
||||
}
|
||||
|
||||
var ErrIssueAlreadyChanged = util.NewInvalidArgumentErrorf("the issue is already changed")
|
||||
var (
|
||||
ErrIssueAlreadyChanged = util.NewInvalidArgumentErrorf("the issue is already changed")
|
||||
ErrNoPosterSetOnIssue = errors.New("the issue has no poster")
|
||||
)
|
||||
|
||||
// Issue represents an issue or pull request of repository.
|
||||
type Issue struct {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ func mustGetIssuePoster(ctx context.Context, issue *issues_model.Issue) (*user_m
|
|||
return issue.Poster, nil
|
||||
}
|
||||
if issue.PosterID == 0 {
|
||||
return nil, user_model.ErrUserNotExist{}
|
||||
return nil, issues_model.ErrNoPosterSetOnIssue
|
||||
}
|
||||
|
||||
poster, err := user_model.GetPossibleUserByID(ctx, issue.PosterID)
|
||||
|
|
|
|||
|
|
@ -392,7 +392,7 @@ func TestActionsTrust_GetPullRequestUserIsTrustedWithActions(t *testing.T) {
|
|||
t.Run("no poster set on issue linked to pull request", func(t *testing.T) {
|
||||
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 6000})
|
||||
posterTrust, err := GetPullRequestPosterIsTrustedWithActions(t.Context(), pr)
|
||||
require.ErrorIs(t, err, user_model.ErrUserNotExist{})
|
||||
require.ErrorIs(t, err, issues_model.ErrNoPosterSetOnIssue)
|
||||
require.Equal(t, UserIsNotTrustedWithActions, posterTrust)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue