From 462ed3cee05520bc31e5497d36779f5c1881249b Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 7 Apr 2014 13:13:23 -0700 Subject: [PATCH] consul: Refactor to pull out server config --- consul/server_test.go | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/consul/server_test.go b/consul/server_test.go index f73ec6f2ee..a1f5604793 100644 --- a/consul/server_test.go +++ b/consul/server_test.go @@ -25,19 +25,11 @@ func tmpDir(t *testing.T) string { return dir } -func testServer(t *testing.T) (string, *Server) { - return testServerDC(t, "dc1") -} - -func testServerDC(t *testing.T, dc string) (string, *Server) { - return testServerDCBootstrap(t, dc, true) -} - -func testServerDCBootstrap(t *testing.T, dc string, bootstrap bool) (string, *Server) { +func testServerConfig(t *testing.T) (string, *Config) { dir := tmpDir(t) config := DefaultConfig() - config.Bootstrap = bootstrap - config.Datacenter = dc + config.Bootstrap = true + config.Datacenter = "dc1" config.DataDir = dir // Adjust the ports @@ -65,7 +57,21 @@ func testServerDCBootstrap(t *testing.T, dc string, bootstrap bool) (string, *Se config.RaftConfig.ElectionTimeout = 40 * time.Millisecond config.ReconcileInterval = 100 * time.Millisecond + return dir, config +} +func testServer(t *testing.T) (string, *Server) { + return testServerDC(t, "dc1") +} + +func testServerDC(t *testing.T, dc string) (string, *Server) { + return testServerDCBootstrap(t, dc, true) +} + +func testServerDCBootstrap(t *testing.T, dc string, bootstrap bool) (string, *Server) { + dir, config := testServerConfig(t) + config.Datacenter = dc + config.Bootstrap = bootstrap server, err := NewServer(config) if err != nil { t.Fatalf("err: %v", err)