mirror of https://github.com/status-im/consul.git
api: improve test reliability
This commit is contained in:
parent
86198b9ce7
commit
dc6795a55a
|
@ -2,6 +2,8 @@ package api
|
|||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/consul/testutil"
|
||||
)
|
||||
|
||||
func TestEvent_FireList(t *testing.T) {
|
||||
|
@ -25,16 +27,23 @@ func TestEvent_FireList(t *testing.T) {
|
|||
t.Fatalf("invalid: %v", id)
|
||||
}
|
||||
|
||||
events, qm, err := event.List("", nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
var events []*UserEvent
|
||||
var qm *QueryMeta
|
||||
testutil.WaitForResult(func() (bool, error) {
|
||||
events, qm, err = event.List("", nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
return len(events) > 0, err
|
||||
}, func(err error) {
|
||||
t.Fatalf("err: %#v", err)
|
||||
})
|
||||
|
||||
if events[len(events)-1].ID != id {
|
||||
t.Fatalf("bad: %#v", events)
|
||||
}
|
||||
|
||||
if qm.LastIndex != event.IDToIndex(id) {
|
||||
t.Fatalf("Bad: %#v", qm)
|
||||
}
|
||||
|
||||
if events[len(events)-1].ID != id {
|
||||
t.Fatalf("bad: %#v", events)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue