diff --git a/sd/consul/integration_test.go b/sd/consul/integration_test.go index 95185d8..5961547 100644 --- a/sd/consul/integration_test.go +++ b/sd/consul/integration_test.go @@ -17,7 +17,7 @@ func TestIntegration(t *testing.T) { consulAddr := os.Getenv("CONSUL_ADDR") if consulAddr == "" { - t.Fatal("CONSUL_ADDR is not set") + t.Skip("CONSUL_ADDR not set; skipping integration test") } stdClient, err := stdconsul.NewClient(&stdconsul.Config{ Address: consulAddr, diff --git a/sd/zk/integration_test.go b/sd/zk/integration_test.go index e4aff65..f654123 100644 --- a/sd/zk/integration_test.go +++ b/sd/zk/integration_test.go @@ -4,7 +4,6 @@ import ( "bytes" - "log" "os" "testing" "time" @@ -18,13 +17,16 @@ func TestMain(m *testing.M) { zkAddr := os.Getenv("ZK_ADDR") - if zkAddr == "" { - log.Fatal("ZK_ADDR is not set") - } - host = []string{zkAddr} + if zkAddr != "" { + host = []string{zkAddr} + } + m.Run() } func TestCreateParentNodesOnServer(t *testing.T) { + if len(host) == 0 { + t.Skip("ZK_ADDR not set; skipping integration test") + } payload := [][]byte{[]byte("Payload"), []byte("Test")} c1, err := NewClient(host, logger, Payload(payload)) if err != nil { @@ -67,6 +69,9 @@ } func TestCreateBadParentNodesOnServer(t *testing.T) { + if len(host) == 0 { + t.Skip("ZK_ADDR not set; skipping integration test") + } c, _ := NewClient(host, logger) defer c.Stop() @@ -78,6 +83,9 @@ } func TestCredentials1(t *testing.T) { + if len(host) == 0 { + t.Skip("ZK_ADDR not set; skipping integration test") + } acl := stdzk.DigestACL(stdzk.PermAll, "user", "secret") c, _ := NewClient(host, logger, ACL(acl), Credentials("user", "secret")) defer c.Stop() @@ -90,6 +98,9 @@ } func TestCredentials2(t *testing.T) { + if len(host) == 0 { + t.Skip("ZK_ADDR not set; skipping integration test") + } acl := stdzk.DigestACL(stdzk.PermAll, "user", "secret") c, _ := NewClient(host, logger, ACL(acl)) defer c.Stop() @@ -102,6 +113,9 @@ } func TestConnection(t *testing.T) { + if len(host) == 0 { + t.Skip("ZK_ADDR not set; skipping integration test") + } c, _ := NewClient(host, logger) c.Stop() @@ -113,6 +127,9 @@ } func TestGetEntriesOnServer(t *testing.T) { + if len(host) == 0 { + t.Skip("ZK_ADDR not set; skipping integration test") + } var instancePayload = "10.0.3.204:8002" c1, err := NewClient(host, logger) @@ -158,6 +175,9 @@ } func TestGetEntriesPayloadOnServer(t *testing.T) { + if len(host) == 0 { + t.Skip("ZK_ADDR not set; skipping integration test") + } c, err := NewClient(host, logger) if err != nil { t.Fatalf("Connect returned error: %v", err)