本站源代码
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

38 lignes
1.0KB

  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package issue
  5. import (
  6. "testing"
  7. "code.gitea.io/gitea/models"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestDeleteNotPassedAssignee(t *testing.T) {
  11. assert.NoError(t, models.PrepareTestDatabase())
  12. // Fake issue with assignees
  13. issue, err := models.GetIssueWithAttrsByID(1)
  14. assert.NoError(t, err)
  15. user1, err := models.GetUserByID(1) // This user is already assigned (see the definition in fixtures), so running UpdateAssignee should unassign him
  16. assert.NoError(t, err)
  17. // Check if he got removed
  18. isAssigned, err := models.IsUserAssignedToIssue(issue, user1)
  19. assert.NoError(t, err)
  20. assert.True(t, isAssigned)
  21. // Clean everyone
  22. err = DeleteNotPassedAssignee(issue, user1, []*models.User{})
  23. assert.NoError(t, err)
  24. // Check they're gone
  25. assignees, err := models.GetAssigneesByIssue(issue)
  26. assert.NoError(t, err)
  27. assert.Equal(t, 0, len(assignees))
  28. }
上海开阖软件有限公司 沪ICP备12045867号-1