1
1
mirror of https://github.com/go-gitea/gitea synced 2024-11-15 14:44:41 +00:00

add test against deactivated user for GetReviewers

This commit is contained in:
m.huber 2024-04-30 01:34:32 +02:00
parent f328a1d794
commit d71562e669

View File

@ -50,7 +50,9 @@ func TestRepoGetReviewers(t *testing.T) {
ctx := db.DefaultContext ctx := db.DefaultContext
reviewers, err := repo_model.GetReviewers(ctx, repo1, 2, 2) reviewers, err := repo_model.GetReviewers(ctx, repo1, 2, 2)
assert.NoError(t, err) assert.NoError(t, err)
assert.Len(t, reviewers, 4) if assert.Len(t, reviewers, 4) {
assert.ElementsMatch(t, []int64{1, 4, 9, 11}, []int64{reviewers[0].ID, reviewers[1].ID, reviewers[2].ID, reviewers[3].ID})
}
// should include doer if doer is not PR poster. // should include doer if doer is not PR poster.
reviewers, err = repo_model.GetReviewers(ctx, repo1, 11, 2) reviewers, err = repo_model.GetReviewers(ctx, repo1, 11, 2)
@ -80,4 +82,13 @@ func TestRepoGetReviewers(t *testing.T) {
reviewers, err = repo_model.GetReviewers(ctx, repo3, 2, 2) reviewers, err = repo_model.GetReviewers(ctx, repo3, 2, 2)
assert.NoError(t, err) assert.NoError(t, err)
assert.Len(t, reviewers, 1) assert.Len(t, reviewers, 1)
// do not return deactivated users
user11 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 11})
user_model.UpdateUserCols(db.DefaultContext, user11, "is_active")
reviewers, err = repo_model.GetReviewers(ctx, repo1, 2, 2)
assert.NoError(t, err)
if assert.Len(t, reviewers, 3) {
assert.NotContains(t, []int64{reviewers[0].ID, reviewers[1].ID, reviewers[2].ID}, 11)
}
} }