You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0 KiB

  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. }