summaryrefslogtreecommitdiffstats
path: root/services/pull/check_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-12-07 10:44:10 +0800
committertechknowlogick <techknowlogick@gitea.io>2019-12-06 21:44:10 -0500
commit82e0383d2104f454af5b3e0e768f0497113f3b13 (patch)
tree0bb945b408668867e24db2429cc7099d57eaa6f6 /services/pull/check_test.go
parent1583c48e3a89fcb9aeb81a57295982ee64d5859f (diff)
downloadgitea-82e0383d2104f454af5b3e0e768f0497113f3b13.tar.gz
gitea-82e0383d2104f454af5b3e0e768f0497113f3b13.zip
Move some pull request functions from models to services (#9266)
* Move some pull request functions from models to services * Fix test
Diffstat (limited to 'services/pull/check_test.go')
-rw-r--r--services/pull/check_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/services/pull/check_test.go b/services/pull/check_test.go
new file mode 100644
index 0000000000..48a7774a61
--- /dev/null
+++ b/services/pull/check_test.go
@@ -0,0 +1,34 @@
+// Copyright 2019 The Gitea Authors.
+// All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package pull
+
+import (
+ "strconv"
+ "testing"
+ "time"
+
+ "code.gitea.io/gitea/models"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPullRequest_AddToTaskQueue(t *testing.T) {
+ assert.NoError(t, models.PrepareTestDatabase())
+
+ pr := models.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 1}).(*models.PullRequest)
+ AddToTaskQueue(pr)
+
+ select {
+ case id := <-pullRequestQueue.Queue():
+ assert.EqualValues(t, strconv.FormatInt(pr.ID, 10), id)
+ case <-time.After(time.Second):
+ assert.Fail(t, "Timeout: nothing was added to pullRequestQueue")
+ }
+
+ assert.True(t, pullRequestQueue.Exist(pr.ID))
+ pr = models.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 1}).(*models.PullRequest)
+ assert.Equal(t, models.PullRequestStatusChecking, pr.Status)
+}