Adds some TODOs and small fixes to pkg/util/workqueue

Adds a new unit test for queue.
This commit is contained in:
Joe Beda
2016-10-21 18:29:36 -07:00
parent e0c6bf13b1
commit 16b3485817
5 changed files with 46 additions and 5 deletions

View File

@@ -129,3 +129,33 @@ func TestLen(t *testing.T) {
t.Errorf("Expected %v, got %v", e, a)
}
}
func TestReinsert(t *testing.T) {
q := workqueue.New()
q.Add("foo")
// Start processing
i, _ := q.Get()
if i != "foo" {
t.Errorf("Expected %v, got %v", "foo", i)
}
// Add it back while processing
q.Add(i)
// Finish it up
q.Done(i)
// It should be back on the queue
i, _ = q.Get()
if i != "foo" {
t.Errorf("Expected %v, got %v", "foo", i)
}
// Finish that one up
q.Done(i)
if a := q.Len(); a != 0 {
t.Errorf("Expected queue to be empty. Has %v items", a)
}
}