From 1db7cb2f012a4ce86e5c40909248bb914e0844f2 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 16 Oct 2013 17:08:14 -0700 Subject: [PATCH] Updated fixes post rebase from master Removed test cases that are no longer applicable with links and the port changes. Remove test case where a test was hitting an external ip. --- api.go | 12 ++++-------- container_test.go | 19 +------------------ runtime.go | 1 - runtime_test.go | 15 ++------------- 4 files changed, 7 insertions(+), 40 deletions(-) diff --git a/api.go b/api.go index 3ff74846f..494a6353b 100644 --- a/api.go +++ b/api.go @@ -71,12 +71,12 @@ func httpError(w http.ResponseWriter, err error) { statusCode = http.StatusUnauthorized } else if strings.Contains(err.Error(), "hasn't been activated") { statusCode = http.StatusForbidden - } - + } + if err != nil { utils.Errorf("HTTP Error: statusCode=%d %s", statusCode, err.Error()) - http.Error(w, err.Error(), statusCode) - } + http.Error(w, err.Error(), statusCode) + } } func writeJSON(w http.ResponseWriter, code int, v interface{}) error { @@ -635,12 +635,8 @@ func postContainersStart(srv *Server, version float64, w http.ResponseWriter, r if vars == nil { return fmt.Errorf("Missing parameter") } - var err error name := vars["name"] name = decodeName(name) - if err != nil { - return err - } if err := srv.ContainerStart(name, hostConfig); err != nil { return err } diff --git a/container_test.go b/container_test.go index 9330988b7..222d5a656 100644 --- a/container_test.go +++ b/container_test.go @@ -410,7 +410,7 @@ func TestOutput(t *testing.T) { func TestContainerNetwork(t *testing.T) { runtime := mkRuntime(t) defer nuke(runtime) - container, err := runtime.Create( + container, _, err := runtime.Create( &Config{ Image: GetTestImage(runtime).ID, Cmd: []string{"ping", "-c", "1", "127.0.0.1"}, @@ -426,23 +426,6 @@ func TestContainerNetwork(t *testing.T) { if container.State.ExitCode != 0 { t.Errorf("Unexpected ping 127.0.0.1 exit code %d (expected 0)", container.State.ExitCode) } - - container, err = runtime.Create( - &Config{ - Image: GetTestImage(runtime).ID, - Cmd: []string{"ping", "-c", "1", "8.8.8.8"}, - }, - ) - if err != nil { - t.Fatal(err) - } - defer runtime.Destroy(container) - if err := container.Run(); err != nil { - t.Fatal(err) - } - if container.State.ExitCode != 0 { - t.Errorf("Unexpected ping 8.8.8.8 exit code %d (expected 0)", container.State.ExitCode) - } } func TestKillDifferentUser(t *testing.T) { diff --git a/runtime.go b/runtime.go index d7a6e8800..8239ddb0b 100644 --- a/runtime.go +++ b/runtime.go @@ -325,7 +325,6 @@ func (runtime *Runtime) Create(config *Config) (*Container, []string, error) { if err := MergeConfig(config, img.Config); err != nil { return nil, nil, err } - } if len(config.Entrypoint) != 0 && config.Cmd == nil { diff --git a/runtime_test.go b/runtime_test.go index 8f73cec27..a81284bb5 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -239,23 +239,12 @@ func TestRuntimeCreate(t *testing.T) { Cmd: []string{"/bin/ls"}, PortSpecs: []string{"80"}, } - container, err = runtime.Create(config) + container, _, err = runtime.Create(config) - image, err := runtime.Commit(container, "testrepo", "testtag", "", "", config) + _, err = runtime.Commit(container, "testrepo", "testtag", "", "", config) if err != nil { t.Error(err) } - - _, err = runtime.Create( - &Config{ - Image: image.ID, - PortSpecs: []string{"80000:80"}, - }, - ) - if err == nil { - t.Fatal("Builder.Create should throw an error when PortSpecs is invalid") - } - } func TestDestroy(t *testing.T) {