Skip to content

Commit

Permalink
consul test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Krawczyk committed Dec 10, 2015
1 parent 64bdd3b commit 9f102c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions consul/consul_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ func TestRegisterServices_shouldReturnErrorOnFailure(t *testing.T) {
err := consul.Register(service)

// then
assert.NotNil(t, err)
assert.Error(t, err)
}

func TestDeregisterServices(t *testing.T) {
t.Parallel()
server := CreateConsulTestServer("dc1", t)
server := CreateNamedConsulTestServer("localhost", "dc1", t)
defer server.Stop()

consul := ConsulClientAtServer(server)
Expand All @@ -153,7 +153,7 @@ func TestDeregisterServices(t *testing.T) {

func TestDeregisterServices_shouldReturnErrorOnFailure(t *testing.T) {
t.Parallel()
server := CreateConsulTestServer("dc1", t)
server := CreateNamedConsulTestServer("localhost", "dc1", t)
defer server.Stop()

consul := ConsulClientAtServer(server)
Expand All @@ -166,7 +166,7 @@ func TestDeregisterServices_shouldReturnErrorOnFailure(t *testing.T) {
err := consul.Deregister("serviceA", server.Config.NodeName)

// then
assert.NotNil(t, err)
assert.Error(t, err)
}

func serviceRegistration(name string, tags []string) *consulapi.AgentServiceRegistration {
Expand Down
8 changes: 7 additions & 1 deletion consul/consul_test_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import (
func CreateConsulTestServer(dc string, t *testing.T) *testutil.TestServer {
return testutil.NewTestServerConfig(t, func(c *testutil.TestServerConfig) {
c.Datacenter = dc
c.NodeName = "localhost"
})
}

func CreateNamedConsulTestServer(hostname string, dc string, t *testing.T) *testutil.TestServer {
return testutil.NewTestServerConfig(t, func(c *testutil.TestServerConfig) {
c.Datacenter = dc
c.NodeName = hostname
})
}

Expand Down

0 comments on commit 9f102c9

Please sign in to comment.