mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Move SaveAndThenload to integration-cli
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
8232cc777e
commit
6f5b895bc7
2 changed files with 31 additions and 61 deletions
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
@ -67,3 +68,33 @@ func TestApiImagesFilter(t *testing.T) {
|
||||||
|
|
||||||
logDone("images - filter param is applied")
|
logDone("images - filter param is applied")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApiImagesSaveAndLoad(t *testing.T) {
|
||||||
|
out, err := buildImage("saveandload", "FROM hello-world\nENV FOO bar", false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
id := strings.TrimSpace(out)
|
||||||
|
defer deleteImages("saveandload")
|
||||||
|
|
||||||
|
_, body, err := sockRequestRaw("GET", "/images/"+id+"/get", nil, "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer body.Close()
|
||||||
|
|
||||||
|
dockerCmd(t, "rmi", id)
|
||||||
|
|
||||||
|
_, loadBody, err := sockRequestRaw("POST", "/images/load", body, "application/x-tar")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer loadBody.Close()
|
||||||
|
|
||||||
|
out, _, _ = dockerCmd(t, "inspect", "--format='{{ .Id }}'", id)
|
||||||
|
if strings.TrimSpace(out) != id {
|
||||||
|
t.Fatal("load did not work properly")
|
||||||
|
}
|
||||||
|
|
||||||
|
logDone("images API - save and load")
|
||||||
|
}
|
||||||
|
|
|
@ -23,67 +23,6 @@ import (
|
||||||
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
|
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSaveImageAndThenLoad(t *testing.T) {
|
|
||||||
eng := NewTestEngine(t)
|
|
||||||
defer mkDaemonFromEngine(eng, t).Nuke()
|
|
||||||
|
|
||||||
// save image
|
|
||||||
r := httptest.NewRecorder()
|
|
||||||
req, err := http.NewRequest("GET", "/images/"+unitTestImageID+"/get", nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
server.ServeRequest(eng, api.APIVERSION, r, req)
|
|
||||||
if r.Code != http.StatusOK {
|
|
||||||
t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code)
|
|
||||||
}
|
|
||||||
tarball := r.Body
|
|
||||||
|
|
||||||
// delete the image
|
|
||||||
r = httptest.NewRecorder()
|
|
||||||
req, err = http.NewRequest("DELETE", "/images/"+unitTestImageID, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
server.ServeRequest(eng, api.APIVERSION, r, req)
|
|
||||||
if r.Code != http.StatusOK {
|
|
||||||
t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code)
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure there is no image
|
|
||||||
r = httptest.NewRecorder()
|
|
||||||
req, err = http.NewRequest("GET", "/images/"+unitTestImageID+"/get", nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
server.ServeRequest(eng, api.APIVERSION, r, req)
|
|
||||||
if r.Code != http.StatusNotFound {
|
|
||||||
t.Fatalf("%d NotFound expected, received %d\n", http.StatusNotFound, r.Code)
|
|
||||||
}
|
|
||||||
|
|
||||||
// load the image
|
|
||||||
r = httptest.NewRecorder()
|
|
||||||
req, err = http.NewRequest("POST", "/images/load", tarball)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
server.ServeRequest(eng, api.APIVERSION, r, req)
|
|
||||||
if r.Code != http.StatusOK {
|
|
||||||
t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code)
|
|
||||||
}
|
|
||||||
|
|
||||||
// finally make sure the image is there
|
|
||||||
r = httptest.NewRecorder()
|
|
||||||
req, err = http.NewRequest("GET", "/images/"+unitTestImageID+"/get", nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
server.ServeRequest(eng, api.APIVERSION, r, req)
|
|
||||||
if r.Code != http.StatusOK {
|
|
||||||
t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetContainersTop(t *testing.T) {
|
func TestGetContainersTop(t *testing.T) {
|
||||||
eng := NewTestEngine(t)
|
eng := NewTestEngine(t)
|
||||||
defer mkDaemonFromEngine(eng, t).Nuke()
|
defer mkDaemonFromEngine(eng, t).Nuke()
|
||||||
|
|
Loading…
Reference in a new issue