nomad: make tests more robust

This commit is contained in:
Armon Dadgar 2015-10-11 18:35:09 -04:00
parent fa58969a12
commit bc7e8fea9e
1 changed files with 18 additions and 3 deletions

View File

@ -52,7 +52,12 @@ func TestWorker_dequeueEvaluation(t *testing.T) {
// Create the evaluation
eval1 := mock.Eval()
s1.evalBroker.Enqueue(eval1)
testutil.WaitForResult(func() (bool, error) {
err := s1.evalBroker.Enqueue(eval1)
return err == nil, err
}, func(err error) {
t.Fatalf("err: %v", err)
})
// Create a worker
w := &Worker{srv: s1, logger: s1.logger}
@ -82,7 +87,12 @@ func TestWorker_dequeueEvaluation_paused(t *testing.T) {
// Create the evaluation
eval1 := mock.Eval()
s1.evalBroker.Enqueue(eval1)
testutil.WaitForResult(func() (bool, error) {
err := s1.evalBroker.Enqueue(eval1)
return err == nil, err
}, func(err error) {
t.Fatalf("err: %v", err)
})
// Create a worker
w := &Worker{srv: s1, logger: s1.logger}
@ -153,7 +163,12 @@ func TestWorker_sendAck(t *testing.T) {
// Create the evaluation
eval1 := mock.Eval()
s1.evalBroker.Enqueue(eval1)
testutil.WaitForResult(func() (bool, error) {
err := s1.evalBroker.Enqueue(eval1)
return err == nil, err
}, func(err error) {
t.Fatalf("err: %v", err)
})
// Create a worker
w := &Worker{srv: s1, logger: s1.logger}