mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 22:06:20 +00:00
Add test function for returning an API client
This commit is contained in:
parent
227019ec59
commit
8c30edc54e
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user