Fix unit test race condition (#2516)

Este commit está contenido en:
Ethan Koenig 2017-09-15 00:54:25 -07:00 cometido por Lauris BH
padre cbe50587ba
commit b496e3e1cc
Se han modificado 1 ficheros con 7 adiciones y 2 borrados

Ver fichero

@ -5,6 +5,7 @@
package models
import (
"strconv"
"testing"
"time"
@ -193,8 +194,12 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) {
pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
pr.AddToTaskQueue()
// briefly sleep so that background threads have time to run
time.Sleep(time.Millisecond)
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 = AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)