Fixing the test
This commit is contained in:
parent
7dab719a66
commit
9b966ec1e6
|
@ -334,3 +334,8 @@ func (c *ConsulService) filterConsulChecks(chks map[string]*consul.AgentCheck) m
|
|||
return nomadChecks
|
||||
|
||||
}
|
||||
|
||||
func (c *ConsulService) consulPresent() bool {
|
||||
_, err := c.client.Agent().Self()
|
||||
return err == nil
|
||||
}
|
||||
|
|
|
@ -16,6 +16,10 @@ func TestConsulServiceRegisterServices(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("Err: %v", err)
|
||||
}
|
||||
// Skipping the test if consul isn't present
|
||||
if !cs.consulPresent() {
|
||||
return
|
||||
}
|
||||
task := structs.Task{
|
||||
Name: "foo",
|
||||
Services: []*structs.Service{
|
||||
|
@ -76,7 +80,7 @@ func TestConsulServiceRegisterServices(t *testing.T) {
|
|||
if _, ok := services["2"]; ok {
|
||||
t.Fatalf("Service with ID 2 should not be registered")
|
||||
}
|
||||
if err := cs.Deregister(); err != nil {
|
||||
if err := cs.Shutdown(); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
|
|
Loading…
Reference in New Issue