2013-05-06 10:59:33 -04:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
2013-11-14 01:10:20 -05:00
|
|
|
"github.com/dotcloud/docker"
|
2013-07-18 10:35:14 -04:00
|
|
|
"github.com/dotcloud/docker/utils"
|
2013-11-08 00:34:54 -05:00
|
|
|
"io/ioutil"
|
2013-11-13 14:25:55 -05:00
|
|
|
"strings"
|
2013-05-06 10:59:33 -04:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2013-05-15 09:11:39 -04:00
|
|
|
func TestContainerTagImageDelete(t *testing.T) {
|
2013-11-14 01:10:20 -05:00
|
|
|
eng := NewTestEngine(t)
|
|
|
|
defer mkRuntimeFromEngine(eng, t).Nuke()
|
2013-05-15 09:11:39 -04:00
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
srv := mkServerFromEngine(eng, t)
|
2013-05-15 09:11:39 -04:00
|
|
|
|
2013-07-01 14:45:45 -04:00
|
|
|
initialImages, err := srv.Images(false, "")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2013-11-14 01:10:20 -05:00
|
|
|
if err := srv.ContainerTag(unitTestImageName, "utest", "tag1", false); err != nil {
|
2013-05-15 09:11:39 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2013-07-31 03:56:53 -04:00
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
if err := srv.ContainerTag(unitTestImageName, "utest/docker", "tag2", false); err != nil {
|
2013-05-15 09:11:39 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2013-11-14 01:10:20 -05:00
|
|
|
if err := srv.ContainerTag(unitTestImageName, "utest:5000/docker", "tag3", false); err != nil {
|
2013-05-15 09:11:39 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
images, err := srv.Images(false, "")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-13 09:42:01 -04:00
|
|
|
if len(images[0].RepoTags) != len(initialImages[0].RepoTags)+3 {
|
|
|
|
t.Errorf("Expected %d images, %d found", len(initialImages)+3, len(images))
|
2013-05-15 09:11:39 -04:00
|
|
|
}
|
|
|
|
|
2013-05-31 10:37:02 -04:00
|
|
|
if _, err := srv.ImageDelete("utest/docker:tag2", true); err != nil {
|
2013-05-15 09:11:39 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
images, err = srv.Images(false, "")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-13 09:42:01 -04:00
|
|
|
if len(images[0].RepoTags) != len(initialImages[0].RepoTags)+2 {
|
2013-07-02 17:47:43 -04:00
|
|
|
t.Errorf("Expected %d images, %d found", len(initialImages)+2, len(images))
|
2013-05-15 09:11:39 -04:00
|
|
|
}
|
|
|
|
|
2013-07-31 03:56:53 -04:00
|
|
|
if _, err := srv.ImageDelete("utest:5000/docker:tag3", true); err != nil {
|
2013-05-15 09:11:39 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
images, err = srv.Images(false, "")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-13 09:42:01 -04:00
|
|
|
if len(images[0].RepoTags) != len(initialImages[0].RepoTags)+1 {
|
2013-07-02 17:47:43 -04:00
|
|
|
t.Errorf("Expected %d images, %d found", len(initialImages)+1, len(images))
|
2013-05-15 09:11:39 -04:00
|
|
|
}
|
|
|
|
|
2013-05-31 10:37:02 -04:00
|
|
|
if _, err := srv.ImageDelete("utest:tag1", true); err != nil {
|
2013-05-15 09:11:39 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
images, err = srv.Images(false, "")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-07-01 14:45:45 -04:00
|
|
|
if len(images) != len(initialImages) {
|
2013-07-02 17:47:43 -04:00
|
|
|
t.Errorf("Expected %d image, %d found", len(initialImages), len(images))
|
2013-05-15 09:11:39 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-06 10:59:33 -04:00
|
|
|
func TestCreateRm(t *testing.T) {
|
2013-10-27 22:20:00 -04:00
|
|
|
eng := NewTestEngine(t)
|
|
|
|
srv := mkServerFromEngine(eng, t)
|
2013-11-14 01:10:20 -05:00
|
|
|
defer mkRuntimeFromEngine(eng, t).Nuke()
|
2013-05-06 10:59:33 -04:00
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
config, _, _, err := docker.ParseRun([]string{unitTestImageID, "echo test"}, nil)
|
2013-05-06 10:59:33 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:20:00 -04:00
|
|
|
id := createTestContainer(eng, config, t)
|
2013-05-06 10:59:33 -04:00
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
if c := srv.Containers(true, false, -1, "", ""); len(c) != 1 {
|
|
|
|
t.Errorf("Expected 1 container, %v found", len(c))
|
2013-05-06 10:59:33 -04:00
|
|
|
}
|
|
|
|
|
2013-10-04 22:25:15 -04:00
|
|
|
if err = srv.ContainerDestroy(id, true, false); err != nil {
|
2013-05-06 10:59:33 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
if c := srv.Containers(true, false, -1, "", ""); len(c) != 0 {
|
|
|
|
t.Errorf("Expected 0 container, %v found", len(c))
|
2013-05-06 10:59:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-08 12:35:47 -04:00
|
|
|
func TestCreateRmVolumes(t *testing.T) {
|
2013-10-27 03:13:45 -04:00
|
|
|
eng := NewTestEngine(t)
|
2013-10-26 22:24:01 -04:00
|
|
|
srv := mkServerFromEngine(eng, t)
|
2013-11-14 01:10:20 -05:00
|
|
|
defer mkRuntimeFromEngine(eng, t).Nuke()
|
2013-10-08 12:35:47 -04:00
|
|
|
|
2013-11-05 20:29:55 -05:00
|
|
|
config, hostConfig, _, err := docker.ParseRun([]string{"-v", "/srv", unitTestImageID, "echo", "test"}, nil)
|
2013-10-08 12:35:47 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:20:00 -04:00
|
|
|
id := createTestContainer(eng, config, t)
|
2013-10-08 12:35:47 -04:00
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
if c := srv.Containers(true, false, -1, "", ""); len(c) != 1 {
|
|
|
|
t.Errorf("Expected 1 container, %v found", len(c))
|
2013-10-08 12:35:47 -04:00
|
|
|
}
|
|
|
|
|
2013-10-26 22:24:01 -04:00
|
|
|
job := eng.Job("start", id)
|
|
|
|
if err := job.ImportEnv(hostConfig); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := job.Run(); err != nil {
|
2013-10-08 12:35:47 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = srv.ContainerStop(id, 1)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-04 22:25:15 -04:00
|
|
|
if err = srv.ContainerDestroy(id, true, false); err != nil {
|
2013-10-08 12:35:47 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
if c := srv.Containers(true, false, -1, "", ""); len(c) != 0 {
|
|
|
|
t.Errorf("Expected 0 container, %v found", len(c))
|
2013-10-08 12:35:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-25 11:20:56 -04:00
|
|
|
func TestCommit(t *testing.T) {
|
2013-10-27 22:20:00 -04:00
|
|
|
eng := NewTestEngine(t)
|
|
|
|
srv := mkServerFromEngine(eng, t)
|
2013-11-14 01:10:20 -05:00
|
|
|
defer mkRuntimeFromEngine(eng, t).Nuke()
|
2013-07-25 11:20:56 -04:00
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
config, _, _, err := docker.ParseRun([]string{unitTestImageID, "/bin/cat"}, nil)
|
2013-07-25 11:20:56 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:20:00 -04:00
|
|
|
id := createTestContainer(eng, config, t)
|
2013-07-25 11:20:56 -04:00
|
|
|
|
|
|
|
if _, err := srv.ContainerCommit(id, "testrepo", "testtag", "", "", config); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-06 10:59:33 -04:00
|
|
|
func TestCreateStartRestartStopStartKillRm(t *testing.T) {
|
2013-10-27 03:13:45 -04:00
|
|
|
eng := NewTestEngine(t)
|
2013-10-26 22:24:01 -04:00
|
|
|
srv := mkServerFromEngine(eng, t)
|
2013-11-14 01:10:20 -05:00
|
|
|
defer mkRuntimeFromEngine(eng, t).Nuke()
|
2013-05-06 10:59:33 -04:00
|
|
|
|
2013-11-11 22:57:29 -05:00
|
|
|
config, hostConfig, _, err := docker.ParseRun([]string{"-i", unitTestImageID, "/bin/cat"}, nil)
|
2013-05-06 10:59:33 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:20:00 -04:00
|
|
|
id := createTestContainer(eng, config, t)
|
2013-05-06 10:59:33 -04:00
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
if c := srv.Containers(true, false, -1, "", ""); len(c) != 1 {
|
|
|
|
t.Errorf("Expected 1 container, %v found", len(c))
|
2013-05-06 10:59:33 -04:00
|
|
|
}
|
|
|
|
|
2013-10-26 22:24:01 -04:00
|
|
|
job := eng.Job("start", id)
|
|
|
|
if err := job.ImportEnv(hostConfig); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := job.Run(); err != nil {
|
2013-05-06 10:59:33 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-08 21:42:53 -04:00
|
|
|
if err := srv.ContainerRestart(id, 15); err != nil {
|
2013-05-06 10:59:33 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-08 21:42:53 -04:00
|
|
|
if err := srv.ContainerStop(id, 15); err != nil {
|
2013-05-06 10:59:33 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-26 22:24:01 -04:00
|
|
|
job = eng.Job("start", id)
|
|
|
|
if err := job.ImportEnv(hostConfig); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := job.Run(); err != nil {
|
2013-05-06 10:59:33 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-08 15:15:29 -04:00
|
|
|
if err := srv.ContainerKill(id, 0); err != nil {
|
2013-05-06 10:59:33 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-05-24 21:31:47 -04:00
|
|
|
// FIXME: this failed once with a race condition ("Unable to remove filesystem for xxx: directory not empty")
|
2013-10-04 22:25:15 -04:00
|
|
|
if err := srv.ContainerDestroy(id, true, false); err != nil {
|
2013-05-06 10:59:33 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
if c := srv.Containers(true, false, -1, "", ""); len(c) != 0 {
|
|
|
|
t.Errorf("Expected 0 container, %v found", len(c))
|
2013-05-06 10:59:33 -04:00
|
|
|
}
|
|
|
|
}
|
2013-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
func TestRunWithTooLowMemoryLimit(t *testing.T) {
|
2013-10-27 22:20:00 -04:00
|
|
|
eng := NewTestEngine(t)
|
2013-11-14 01:10:20 -05:00
|
|
|
defer mkRuntimeFromEngine(eng, t).Nuke()
|
2013-10-08 15:15:29 -04:00
|
|
|
|
2013-06-14 15:55:00 -04:00
|
|
|
// Try to create a container with a memory limit of 1 byte less than the minimum allowed limit.
|
2013-10-27 22:20:00 -04:00
|
|
|
job := eng.Job("create")
|
2013-11-14 01:10:20 -05:00
|
|
|
job.Setenv("Image", unitTestImageID)
|
2013-10-27 22:20:00 -04:00
|
|
|
job.Setenv("Memory", "524287")
|
|
|
|
job.Setenv("CpuShares", "1000")
|
|
|
|
job.SetenvList("Cmd", []string{"/bin/cat"})
|
|
|
|
var id string
|
2013-11-20 02:37:03 -05:00
|
|
|
job.Stdout.AddString(&id)
|
2013-10-27 22:20:00 -04:00
|
|
|
if err := job.Run(); err == nil {
|
2013-06-14 15:55:00 -04:00
|
|
|
t.Errorf("Memory limit is smaller than the allowed limit. Container creation should've failed!")
|
|
|
|
}
|
|
|
|
}
|
2013-07-16 10:38:18 -04:00
|
|
|
|
2013-07-26 06:01:41 -04:00
|
|
|
func TestRmi(t *testing.T) {
|
2013-10-27 03:13:45 -04:00
|
|
|
eng := NewTestEngine(t)
|
2013-10-26 22:24:01 -04:00
|
|
|
srv := mkServerFromEngine(eng, t)
|
2013-11-14 01:10:20 -05:00
|
|
|
defer mkRuntimeFromEngine(eng, t).Nuke()
|
2013-07-26 06:01:41 -04:00
|
|
|
|
|
|
|
initialImages, err := srv.Images(false, "")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-11-05 20:29:55 -05:00
|
|
|
config, hostConfig, _, err := docker.ParseRun([]string{unitTestImageID, "echo", "test"}, nil)
|
2013-07-26 06:01:41 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:20:00 -04:00
|
|
|
containerID := createTestContainer(eng, config, t)
|
2013-07-26 06:01:41 -04:00
|
|
|
|
|
|
|
//To remove
|
2013-10-26 22:24:01 -04:00
|
|
|
job := eng.Job("start", containerID)
|
|
|
|
if err := job.ImportEnv(hostConfig); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := job.Run(); err != nil {
|
2013-07-26 06:01:41 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-11-12 11:21:02 -05:00
|
|
|
if _, err := srv.ContainerWait(containerID); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-07-26 06:01:41 -04:00
|
|
|
imageID, err := srv.ContainerCommit(containerID, "test", "", "", "", nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = srv.ContainerTag(imageID, "test", "0.1", false)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:20:00 -04:00
|
|
|
containerID = createTestContainer(eng, config, t)
|
2013-07-26 06:01:41 -04:00
|
|
|
|
|
|
|
//To remove
|
2013-10-26 22:24:01 -04:00
|
|
|
job = eng.Job("start", containerID)
|
|
|
|
if err := job.ImportEnv(hostConfig); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := job.Run(); err != nil {
|
2013-07-26 06:01:41 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-11-12 11:21:02 -05:00
|
|
|
if _, err := srv.ContainerWait(containerID); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-07-26 06:01:41 -04:00
|
|
|
_, err = srv.ContainerCommit(containerID, "test", "", "", "", nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
images, err := srv.Images(false, "")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(images)-len(initialImages) != 2 {
|
|
|
|
t.Fatalf("Expected 2 new images, found %d.", len(images)-len(initialImages))
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = srv.ImageDelete(imageID, true)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
images, err = srv.Images(false, "")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(images)-len(initialImages) != 1 {
|
|
|
|
t.Fatalf("Expected 1 new image, found %d.", len(images)-len(initialImages))
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, image := range images {
|
|
|
|
if strings.Contains(unitTestImageID, image.ID) {
|
|
|
|
continue
|
|
|
|
}
|
2013-10-13 09:42:01 -04:00
|
|
|
if image.RepoTags[0] == "<none>:<none>" {
|
2013-07-26 06:01:41 -04:00
|
|
|
t.Fatalf("Expected tagged image, got untagged one.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-06 16:16:10 -04:00
|
|
|
|
|
|
|
func TestImagesFilter(t *testing.T) {
|
2013-11-14 01:10:20 -05:00
|
|
|
eng := NewTestEngine(t)
|
|
|
|
defer nuke(mkRuntimeFromEngine(eng, t))
|
2013-09-06 16:16:10 -04:00
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
srv := mkServerFromEngine(eng, t)
|
2013-09-06 16:16:10 -04:00
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
if err := srv.ContainerTag(unitTestImageName, "utest", "tag1", false); err != nil {
|
2013-09-06 16:16:10 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-11-14 01:10:20 -05:00
|
|
|
if err := srv.ContainerTag(unitTestImageName, "utest/docker", "tag2", false); err != nil {
|
2013-09-06 16:16:10 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2013-11-14 01:10:20 -05:00
|
|
|
if err := srv.ContainerTag(unitTestImageName, "utest:5000/docker", "tag3", false); err != nil {
|
2013-09-06 16:16:10 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
images, err := srv.Images(false, "utest*/*")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-13 09:42:01 -04:00
|
|
|
if len(images[0].RepoTags) != 2 {
|
2013-09-06 16:16:10 -04:00
|
|
|
t.Fatal("incorrect number of matches returned")
|
|
|
|
}
|
|
|
|
|
|
|
|
images, err = srv.Images(false, "utest")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-13 09:42:01 -04:00
|
|
|
if len(images[0].RepoTags) != 1 {
|
2013-09-06 16:16:10 -04:00
|
|
|
t.Fatal("incorrect number of matches returned")
|
|
|
|
}
|
|
|
|
|
|
|
|
images, err = srv.Images(false, "utest*")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-13 09:42:01 -04:00
|
|
|
if len(images[0].RepoTags) != 1 {
|
2013-09-06 16:16:10 -04:00
|
|
|
t.Fatal("incorrect number of matches returned")
|
|
|
|
}
|
|
|
|
|
|
|
|
images, err = srv.Images(false, "*5000*/*")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2013-10-13 09:42:01 -04:00
|
|
|
if len(images[0].RepoTags) != 1 {
|
2013-09-06 16:16:10 -04:00
|
|
|
t.Fatal("incorrect number of matches returned")
|
|
|
|
}
|
|
|
|
}
|
2013-11-08 00:34:54 -05:00
|
|
|
|
|
|
|
func TestImageInsert(t *testing.T) {
|
2013-11-14 01:10:20 -05:00
|
|
|
eng := NewTestEngine(t)
|
|
|
|
defer mkRuntimeFromEngine(eng, t).Nuke()
|
|
|
|
srv := mkServerFromEngine(eng, t)
|
2013-11-08 00:34:54 -05:00
|
|
|
sf := utils.NewStreamFormatter(true)
|
|
|
|
|
|
|
|
// bad image name fails
|
|
|
|
if err := srv.ImageInsert("foo", "https://www.docker.io/static/img/docker-top-logo.png", "/foo", ioutil.Discard, sf); err == nil {
|
|
|
|
t.Fatal("expected an error and got none")
|
|
|
|
}
|
|
|
|
|
|
|
|
// bad url fails
|
2013-11-14 01:10:20 -05:00
|
|
|
if err := srv.ImageInsert(unitTestImageID, "http://bad_host_name_that_will_totally_fail.com/", "/foo", ioutil.Discard, sf); err == nil {
|
2013-11-08 00:34:54 -05:00
|
|
|
t.Fatal("expected an error and got none")
|
|
|
|
}
|
|
|
|
|
|
|
|
// success returns nil
|
2013-11-14 01:10:20 -05:00
|
|
|
if err := srv.ImageInsert(unitTestImageID, "https://www.docker.io/static/img/docker-top-logo.png", "/foo", ioutil.Discard, sf); err != nil {
|
2013-11-08 00:34:54 -05:00
|
|
|
t.Fatalf("expected no error, but got %v", err)
|
|
|
|
}
|
|
|
|
}
|