You've already forked woodpecker
							
							
				mirror of
				https://github.com/woodpecker-ci/woodpecker.git
				synced 2025-10-30 23:27:39 +02:00 
			
		
		
		
	add error when removing item not exists
This commit is contained in:
		| @@ -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 | ||||
|  | ||||
|   | ||||
| @@ -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() { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user