mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 04:11:03 +00:00
add error when removing item not exists
This commit is contained in:
parent
1d1dff0dcf
commit
39e7ce9840
2 changed files with 5 additions and 1 deletions
|
@ -1,11 +1,14 @@
|
||||||
package builtin
|
package builtin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/drone/drone/queue"
|
"github.com/drone/drone/queue"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ErrNotFound = errors.New("work item not found")
|
||||||
|
|
||||||
type Queue struct {
|
type Queue struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
|
||||||
|
@ -40,7 +43,7 @@ func (q *Queue) Remove(work *queue.Work) error {
|
||||||
|
|
||||||
_, ok := q.items[work]
|
_, ok := q.items[work]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return ErrNotFound
|
||||||
}
|
}
|
||||||
var items []*queue.Work
|
var items []*queue.Work
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ func TestBuild(t *testing.T) {
|
||||||
g.Assert(len(q.itemc)).Equal(2)
|
g.Assert(len(q.itemc)).Equal(2)
|
||||||
g.Assert(q.Pull()).Equal(w1)
|
g.Assert(q.Pull()).Equal(w1)
|
||||||
g.Assert(q.Pull()).Equal(w3)
|
g.Assert(q.Pull()).Equal(w3)
|
||||||
|
g.Assert(q.Remove(w2)).Equal(ErrNotFound)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should pull item", func() {
|
g.It("Should pull item", func() {
|
||||||
|
|
Loading…
Reference in a new issue