From 8c30edc54ef54eb026c6c88db3c38edf7cbfa5a2 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 26 Sep 2016 10:08:47 -0500 Subject: [PATCH] Add test function for returning an API client --- command/util_test.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/command/util_test.go b/command/util_test.go index a48f33cb0c..e06492aa02 100644 --- a/command/util_test.go +++ b/command/util_test.go @@ -2,8 +2,6 @@ package command import ( "fmt" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/consul" "io" "io/ioutil" "math/rand" @@ -12,6 +10,10 @@ import ( "sync/atomic" "testing" "time" + + "github.com/hashicorp/consul/api" + "github.com/hashicorp/consul/command/agent" + "github.com/hashicorp/consul/consul" ) var offset uint64 @@ -42,6 +44,15 @@ func testAgent(t *testing.T) *agentWrapper { return testAgentWithConfig(t, func(c *agent.Config) {}) } +func testAgentWithAPIClient(t *testing.T) (*agentWrapper, *api.Client) { + agent := testAgentWithConfig(t, func(c *agent.Config) {}) + client, err := api.NewClient(&api.Config{Address: agent.httpAddr}) + if err != nil { + t.Fatalf("consul client: %#v", err) + } + return agent, client +} + func testAgentWithConfig(t *testing.T, cb func(c *agent.Config)) *agentWrapper { l, err := net.Listen("tcp", "127.0.0.1:0") if err != nil {