mirror of https://github.com/status-im/consul.git
Merge pull request #1846 from TeaBough/master
Define a TestingT interface in server.go
This commit is contained in:
commit
7510f00100
|
@ -24,7 +24,6 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/hashicorp/go-cleanhttp"
|
"github.com/hashicorp/go-cleanhttp"
|
||||||
)
|
)
|
||||||
|
@ -112,6 +111,15 @@ type TestCheck struct {
|
||||||
TTL string `json:",omitempty"`
|
TTL string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestingT is an interface wrapper around TestingT
|
||||||
|
type TestingT interface {
|
||||||
|
Logf(format string, args ...interface{})
|
||||||
|
Errorf(format string, args ...interface{})
|
||||||
|
Fatalf(format string, args ...interface{})
|
||||||
|
Fatal(args ...interface{})
|
||||||
|
Skip(args ...interface{})
|
||||||
|
}
|
||||||
|
|
||||||
// TestKVResponse is what we use to decode KV data.
|
// TestKVResponse is what we use to decode KV data.
|
||||||
type TestKVResponse struct {
|
type TestKVResponse struct {
|
||||||
Value string
|
Value string
|
||||||
|
@ -121,7 +129,7 @@ type TestKVResponse struct {
|
||||||
type TestServer struct {
|
type TestServer struct {
|
||||||
PID int
|
PID int
|
||||||
Config *TestServerConfig
|
Config *TestServerConfig
|
||||||
t *testing.T
|
t TestingT
|
||||||
|
|
||||||
HTTPAddr string
|
HTTPAddr string
|
||||||
LANAddr string
|
LANAddr string
|
||||||
|
@ -132,13 +140,13 @@ type TestServer struct {
|
||||||
|
|
||||||
// NewTestServer is an easy helper method to create a new Consul
|
// NewTestServer is an easy helper method to create a new Consul
|
||||||
// test server with the most basic configuration.
|
// test server with the most basic configuration.
|
||||||
func NewTestServer(t *testing.T) *TestServer {
|
func NewTestServer(t TestingT) *TestServer {
|
||||||
return NewTestServerConfig(t, nil)
|
return NewTestServerConfig(t, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTestServerConfig creates a new TestServer, and makes a call to
|
// NewTestServerConfig creates a new TestServer, and makes a call to
|
||||||
// an optional callback function to modify the configuration.
|
// an optional callback function to modify the configuration.
|
||||||
func NewTestServerConfig(t *testing.T, cb ServerConfigCallback) *TestServer {
|
func NewTestServerConfig(t TestingT, cb ServerConfigCallback) *TestServer {
|
||||||
if path, err := exec.LookPath("consul"); err != nil || path == "" {
|
if path, err := exec.LookPath("consul"); err != nil || path == "" {
|
||||||
t.Skip("consul not found on $PATH, skipping")
|
t.Skip("consul not found on $PATH, skipping")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue