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.

check_test.go 919B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2019 The Gitea Authors.
  2. // All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package pull
  6. import (
  7. "strconv"
  8. "testing"
  9. "time"
  10. "code.gitea.io/gitea/models"
  11. "github.com/stretchr/testify/assert"
  12. )
  13. func TestPullRequest_AddToTaskQueue(t *testing.T) {
  14. assert.NoError(t, models.PrepareTestDatabase())
  15. pr := models.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
  16. AddToTaskQueue(pr)
  17. select {
  18. case id := <-pullRequestQueue.Queue():
  19. assert.EqualValues(t, strconv.FormatInt(pr.ID, 10), id)
  20. case <-time.After(time.Second):
  21. assert.Fail(t, "Timeout: nothing was added to pullRequestQueue")
  22. }
  23. assert.True(t, pullRequestQueue.Exist(pr.ID))
  24. pr = models.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
  25. assert.Equal(t, models.PullRequestStatusChecking, pr.Status)
  26. }