Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk: add NewTestServerT, deprecate NewTestServer #6761

Merged
merged 2 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdk/testutil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ import (

func TestFoo_bar(t *testing.T) {
// Create a test Consul server
srv1, err := testutil.NewTestServer()
srv1, err := testutil.NewTestServerT(t)
if err != nil {
t.Fatal(err)
}
defer srv1.Stop()

// Create a secondary server, passing in configuration
// to avoid bootstrapping as we are forming a cluster.
srv2, err := testutil.NewTestServerConfig(t, func(c *testutil.TestServerConfig) {
srv2, err := testutil.NewTestServerConfigT(t, func(c *testutil.TestServerConfig) {
c.Bootstrap = false
})
if err != nil {
Expand Down
12 changes: 10 additions & 2 deletions sdk/testutil/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,20 @@ type TestServer struct {
tmpdir string
}

// NewTestServer is an easy helper method to create a new Consul
// test server with the most basic configuration.
// Deprecated: Use NewTestServerT instead.
func NewTestServer() (*TestServer, error) {
return NewTestServerConfigT(nil, nil)
}

// NewTestServerT is an easy helper method to create a new Consul
// test server with the most basic configuration.
func NewTestServerT(t *testing.T) (*TestServer, error) {
mikemorris marked this conversation as resolved.
Show resolved Hide resolved
if t == nil {
return nil, errors.New("testutil: a non-nil *testing.T is required")
}
return NewTestServerConfigT(t, nil)
}

func NewTestServerConfig(cb ServerConfigCallback) (*TestServer, error) {
return NewTestServerConfigT(nil, cb)
}
Expand Down