Add test function for returning an API client

This commit is contained in:
Seth Vargo 2016-09-26 10:08:47 -05:00
parent 227019ec59
commit 8c30edc54e
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787

View File

@ -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 {