diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index 26a8f115d7..5edd917f07 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -665,3 +665,32 @@ func TestContainerApiTop(t *testing.T) { logDone("containers REST API - GET /containers//top") } + +func TestContainerApiCommit(t *testing.T) { + out, _, _ := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch /test") + id := strings.TrimSpace(out) + + name := "testcommit" + _, b, err := sockRequest("POST", "/commit?repo="+name+"&testtag=tag&container="+id, nil) + if err != nil && !strings.Contains(err.Error(), "200 OK: 201") { + t.Fatal(err) + } + + type resp struct { + Id string + } + var img resp + if err := json.Unmarshal(b, &img); err != nil { + t.Fatal(err) + } + defer deleteImages(img.Id) + + out, err = inspectField(img.Id, "Config.Cmd") + if out != "[/bin/sh -c touch /test]" { + t.Fatalf("got wrong Cmd from commit: %q", out) + } + // sanity check, make sure the image is what we think it is + dockerCmd(t, "run", img.Id, "ls", "/test") + + logDone("containers REST API - POST /commit") +} diff --git a/integration/api_test.go b/integration/api_test.go index 476fa35b37..9ccab1c3b3 100644 --- a/integration/api_test.go +++ b/integration/api_test.go @@ -17,50 +17,11 @@ import ( "github.com/docker/docker/api" "github.com/docker/docker/api/server" "github.com/docker/docker/api/types" - "github.com/docker/docker/builder" "github.com/docker/docker/engine" "github.com/docker/docker/runconfig" "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" ) -func TestPostCommit(t *testing.T) { - eng := NewTestEngine(t) - b := &builder.BuilderJob{Engine: eng} - b.Install() - defer mkDaemonFromEngine(eng, t).Nuke() - - // Create a container and remove a file - containerID := createTestContainer(eng, - &runconfig.Config{ - Image: unitTestImageID, - Cmd: runconfig.NewCommand("touch", "/test"), - }, - t, - ) - - containerRun(eng, containerID, t) - - req, err := http.NewRequest("POST", "/commit?repo=testrepo&testtag=tag&container="+containerID, bytes.NewReader([]byte{})) - if err != nil { - t.Fatal(err) - } - - r := httptest.NewRecorder() - server.ServeRequest(eng, api.APIVERSION, r, req) - assertHttpNotError(r, t) - if r.Code != http.StatusCreated { - t.Fatalf("%d Created expected, received %d\n", http.StatusCreated, r.Code) - } - - var env engine.Env - if err := env.Decode(r.Body); err != nil { - t.Fatal(err) - } - if err := eng.Job("image_inspect", env.Get("Id")).Run(); err != nil { - t.Fatalf("The image has not been committed") - } -} - func TestPostContainersCreate(t *testing.T) { eng := NewTestEngine(t) defer mkDaemonFromEngine(eng, t).Nuke()