diff --git a/ctl/export_test.go b/ctl/export_test.go index d405c92c4..8960702f6 100644 --- a/ctl/export_test.go +++ b/ctl/export_test.go @@ -44,24 +44,16 @@ func TestExportCommand_Validation(t *testing.T) { } func TestExportCommand_Run(t *testing.T) { - t.Skip() // Until test.NewServer() works + cmd := test.MustRunMainWithCluster(t, 1)[0] buf := bytes.Buffer{} stdin, stdout, stderr := GetIO(buf) cm := NewExportCommand(stdin, stdout, stderr) + hostport := cmd.Server.URI.HostPort() + cm.Host = hostport - hldr := test.MustOpenHolder() - defer hldr.Close() - s := test.NewServer() - defer s.Close() - - s.Handler.API.Cluster = test.NewCluster(1) - s.Handler.API.Cluster.Nodes[0].URI = s.HostURI() - s.Handler.API.Holder = hldr.Holder - cm.Host = s.Host() - - http.DefaultClient.Do(test.MustNewHTTPRequest("POST", s.URL+"/index/i", strings.NewReader(""))) - http.DefaultClient.Do(test.MustNewHTTPRequest("POST", s.URL+"/index/i/field/f", strings.NewReader(""))) + http.DefaultClient.Do(test.MustNewHTTPRequest("POST", "http://"+hostport+"/index/i", strings.NewReader(""))) + http.DefaultClient.Do(test.MustNewHTTPRequest("POST", "http://"+hostport+"/index/i/field/f", strings.NewReader(""))) cm.Index = "i" cm.Field = "f" diff --git a/ctl/import_test.go b/ctl/import_test.go index df2b9a5a6..2cf03a126 100644 --- a/ctl/import_test.go +++ b/ctl/import_test.go @@ -29,8 +29,6 @@ import ( ) func TestImportCommand_Validation(t *testing.T) { - t.Skip() // Until test.NewServer() works - buf := bytes.Buffer{} stdin, stdout, stderr := GetIO(buf) cm := NewImportCommand(stdin, stdout, stderr) @@ -53,8 +51,6 @@ func TestImportCommand_Validation(t *testing.T) { } func TestImportCommand_Run(t *testing.T) { - t.Skip() // Until test.NewServer() works - buf := bytes.Buffer{} stdin, stdout, stderr := GetIO(buf) cm := NewImportCommand(stdin, stdout, stderr) @@ -65,15 +61,8 @@ func TestImportCommand_Run(t *testing.T) { t.Fatal(err) } - hldr := test.MustOpenHolder() - defer hldr.Close() - s := test.NewServer() - defer s.Close() - - s.Handler.API.Cluster = test.NewCluster(1) - s.Handler.API.Cluster.Nodes[0].URI = s.HostURI() - s.Handler.API.Holder = hldr.Holder - cm.Host = s.Host() + cmd := test.MustRunMainWithCluster(t, 1)[0] + cm.Host = cmd.Server.URI.HostPort() cm.Index = "i" cm.Field = "f" @@ -87,8 +76,6 @@ func TestImportCommand_Run(t *testing.T) { // Ensure that the ImportValue path runs. func TestImportCommand_RunValue(t *testing.T) { - t.Skip() // Until test.NewServer() works - buf := bytes.Buffer{} stdin, stdout, stderr := GetIO(buf) cm := NewImportCommand(stdin, stdout, stderr) @@ -99,18 +86,12 @@ func TestImportCommand_RunValue(t *testing.T) { t.Fatal(err) } - hldr := test.MustOpenHolder() - defer hldr.Close() - s := test.NewServer() - defer s.Close() + cmd := test.MustRunMainWithCluster(t, 1)[0] + hostport := cmd.Server.URI.HostPort() + cm.Host = hostport - s.Handler.API.Cluster = test.NewCluster(1) - s.Handler.API.Cluster.Nodes[0].URI = s.HostURI() - s.Handler.API.Holder = hldr.Holder - cm.Host = s.Host() - - http.DefaultClient.Do(MustNewHTTPRequest("POST", s.URL+"/index/i", strings.NewReader(""))) - http.DefaultClient.Do(MustNewHTTPRequest("POST", s.URL+"/index/i/field/f", strings.NewReader(`{"options":{"type": "int", "min": 0, "max": 100}}`))) + http.DefaultClient.Do(MustNewHTTPRequest("POST", "http://"+hostport+"/index/i", strings.NewReader(""))) + http.DefaultClient.Do(MustNewHTTPRequest("POST", "http://"+hostport+"/index/i/field/f", strings.NewReader(`{"options":{"type": "int", "min": 0, "max": 100}}`))) cm.Index = "i" cm.Field = "f" @@ -122,21 +103,12 @@ func TestImportCommand_RunValue(t *testing.T) { } func TestImportCommand_InvalidFile(t *testing.T) { - t.Skip() // Until test.NewServer() works - - hldr := test.MustOpenHolder() - defer hldr.Close() - s := test.NewServer() - defer s.Close() - - s.Handler.API.Cluster = test.NewCluster(1) - s.Handler.API.Cluster.Nodes[0].URI = s.HostURI() - s.Handler.API.Holder = hldr.Holder + cmd := test.MustRunMainWithCluster(t, 1)[0] buf := bytes.Buffer{} stdin, stdout, stderr := GetIO(buf) cm := NewImportCommand(stdin, stdout, stderr) - cm.Host = s.Host() + cm.Host = cmd.Server.URI.HostPort() cm.Index = "i" cm.Field = "f" file, err := ioutil.TempFile("", "import.csv")