add error when removing item not exists

This commit is contained in:
Brad Rydzewski 2015-04-23 16:32:46 -07:00
parent 1d1dff0dcf
commit 39e7ce9840
2 changed files with 5 additions and 1 deletions

View file

@ -1,11 +1,14 @@
package builtin
import (
"errors"
"sync"
"github.com/drone/drone/queue"
)
var ErrNotFound = errors.New("work item not found")
type Queue struct {
sync.Mutex
@ -40,7 +43,7 @@ func (q *Queue) Remove(work *queue.Work) error {
_, ok := q.items[work]
if !ok {
return nil
return ErrNotFound
}
var items []*queue.Work

View file

@ -34,6 +34,7 @@ func TestBuild(t *testing.T) {
g.Assert(len(q.itemc)).Equal(2)
g.Assert(q.Pull()).Equal(w1)
g.Assert(q.Pull()).Equal(w3)
g.Assert(q.Remove(w2)).Equal(ErrNotFound)
})
g.It("Should pull item", func() {