func makeClient(t *testing.T, cb1 configCallback, cb2 testutil.ServerConfigCallback) (*Client, *testutil.TestServer) { // Always run these tests in parallel. Check if we have already // marked the current test, as more than 1 call causes panics. if _, ok := seen[t]; !ok { seen[t] = struct{}{} t.Parallel() } // Make client config conf := DefaultConfig() if cb1 != nil { cb1(conf) } // Create server server := testutil.NewTestServer(t, cb2) conf.Address = "http://" + server.HTTPAddr // Create client client, err := NewClient(conf) if err != nil { t.Fatalf("err: %v", err) } return client, server }
func makeClient(t *testing.T, cb1 configCallback, cb2 testutil.ServerConfigCallback) (*Client, *testutil.TestServer) { // Make client config conf := DefaultConfig() if cb1 != nil { cb1(conf) } // Create server server := testutil.NewTestServer(t, cb2) conf.Address = "http://" + server.HTTPAddr // Create client client, err := NewClient(conf) if err != nil { t.Fatalf("err: %v", err) } return client, server }
func testServer( t *testing.T, cb testutil.ServerConfigCallback) (*testutil.TestServer, *api.Client, string) { // Always run these tests in parallel. if _, ok := seen[t]; !ok { seen[t] = struct{}{} t.Parallel() } // Make a new test server srv := testutil.NewTestServer(t, cb) // Make a client clientConf := api.DefaultConfig() clientConf.Address = "http://" + srv.HTTPAddr client, err := api.NewClient(clientConf) if err != nil { t.Fatalf("err: %s", err) } return srv, client, clientConf.Address }