1faf1110aa
This is necessary as consul-api's tests require a real consul instance to be running. We can't directly import an agent to fire up an instance, due to the way this would create an import cycle. These tests instead will start a consul instance using the binary in $PATH (if it exists).
40 lines
605 B
Go
40 lines
605 B
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestEvent_FireList(t *testing.T) {
|
|
c, s := makeClient(t)
|
|
defer s.stop()
|
|
|
|
event := c.Event()
|
|
|
|
params := &UserEvent{Name: "foo"}
|
|
id, meta, err := event.Fire(params, nil)
|
|
if err != nil {
|
|
t.Fatalf("err: %v", err)
|
|
}
|
|
|
|
if meta.RequestTime == 0 {
|
|
t.Fatalf("bad: %v", meta)
|
|
}
|
|
|
|
if id == "" {
|
|
t.Fatalf("invalid: %v", id)
|
|
}
|
|
|
|
events, qm, err := event.List("", nil)
|
|
if err != nil {
|
|
t.Fatalf("err: %v", err)
|
|
}
|
|
|
|
if qm.LastIndex != event.IDToIndex(id) {
|
|
t.Fatalf("Bad: %#v", qm)
|
|
}
|
|
|
|
if events[len(events)-1].ID != id {
|
|
t.Fatalf("bad: %#v", events)
|
|
}
|
|
}
|